Cast, example
#include <stdio.h>
main()
{
int i, j;
float x, y, z;
i = 1;
j = 3;
x = i/j;
y = (float) i / j;
z = (float) i / (float) j;
printf("x=%f,\ny=%f,\n"
"z=%f.\n", x, y, z);
}
prints out:
x=0.000000,
y=0.333333,
z=0.333333.
This is program
ex3.c
Previous slide
Next slide
Back to first slide
View graphic version