C Programming :: Variables & Data Types - Discussion
5 / 51
#include<stdio.h>
int main(){
float x;
x=(int)5.6f*3.2f/sizeof((int)6.6);
printf("%f",x);
return 0;
}
#include<stdio.h>
int main(){
float x;
x=(int)5.6f*3.2f/sizeof((int)6.6);
printf("%f",x);
return 0;
}
A8.96
B9.6
C8
D2
ECompilation error
Show Explanation
In line 4-
x=(int)5.6f*3.2f/sizeof((int)6.6);
or, x=(int)5.6f*3.2f/sizeof(6); [Since, we are typecasting 6.6 to int]
or, x=(int)5.6f*3.2f/4; [Since, 6 is integer type, and size of int is 4 bytes]
or, x=(int)4.48;
or, x=4; [Since, 4.48 is typecasted to int]
In line 5, we are converting int x=4 to float type and we are printing it.
Hence, the output is 4.000000.
Asked In ::
Variable x is initially declared as float.
In line 4-
x=(int)5.6f*3.2f/sizeof((int)6.6);
or, x=(int)5.6f*3.2f/sizeof(6); [Since, we are typecasting 6.6 to int]
or, x=(int)5.6f*3.2f/4; [Since, 6 is integer type, and size of int is 4 bytes]
or, x=(int)4.48;
or, x=4; [Since, 4.48 is typecasted to int]
In line 5, we are converting int x=4 to float type and we are printing it.
Hence, the output is 4.000000.
Read Full Answer
Report Error
Please Login First Click Here