Code:
* Ex.c: Outputs the nearest integer of the input number */
#include <stdio.h>
int main(){
float in;
int out;
printf("Enter a real number: ");
scanf("%f", &in);
out = (int)(in + 0.5);
printf("%f rounded == %d", out);
return 0;
}
The above program is intended to output the nearest integer of the input real number.I did not include the in variable to test what it will put out , I was expecting 23.00000..... something like that as I did input 23.25 But the out put was
D:\C++\TIC\Chap02>Ex
Enter a real number: 23.25
0.000000 rounded == 1102708736
Why am I not getting 23.000000 something?
What makes this output ,when an floating point format specifier is used to output an integer