int to float type casting in c code example
Example 1: casting in c
#include <stdio.h>
#include <stdlib.h>
int main(){
int x = 7, y = 5;
float z;
z = (float)x / (float)y; /*Here the value of z is 1.400000*/
return 0;
}
Example 2: c float to int
# you can cast in c like so
float my_float= 1.446;
int my_int = (int) my_float;
Example 3: how to cast in c programming
(new_type) name_var;
Example 4: int to float c
float percentage;
percentage = (float)number/total * 100;