Please help me in understanding the following C Output:
#include
int main() {
float x = 4.0;
printf("%f\n",x);
printf("%d\n",x);
int y=x;
printf("%d\n",y);
return 0;
}
Ouput on gcc compiler
4.000000
0
4
As far as i have read when we assign float to an int variable the decimal part of the variable is terminated and then assigned to the int.
Why it is not happening in this case?
JavaScript questions and answers, JavaScript questions pdf, JavaScript question bank, JavaScript questions and answers pdf, mcq on JavaScript pdf, JavaScript questions and solutions, JavaScript mcq Test , Interview JavaScript questions, JavaScript Questions for Interview, JavaScript MCQ (Multiple Choice Questions)