|
float A, B, C; - Defines 3 float variables A = 4; B = 5; C = A + B; |
|
int A; - Defines integer float B, C; - Defines 2 float variables A = 4; // Integer B = 5; // Float C = A + B; - The value of A is converted to FLOAT first - Then the addition is performed |
|
|
|
Example:
int main(int argc, char* argv[] ) { int i; short s; double d; i = 9827563; s = i; /* Unsafe conversion, allowed in C !!! */ printf( "i = %d , s = %d \n", i, s ); d = 9827563.444; i = d; /* Unsafe conversion, allowed in C !!! */ printf( "d = %lf , i = %d \n", d, i ); d = 9827563.444; s = d; /* Unsafe conversion, allowed in C !!! */ printf( "d = %lf , s = %d \n", d, s ); } |
How to run the program:
|