TCS
Company
Programming
Technical
What is the output of the following program?
#include
int main(){
double d=5.2;
int i=5;
printf("%dt",sizeof(!d));
printf("%dt",sizeof(i=15/2));
printf("%d",i);
return 0;
}
Read Solution (Total 13)
-
- Output : 2 2 5
sizeof(!d) => sizeof(!5.2) => sizeof(0) => sizeof(int) = 2 [since 0 is an integer]
sizeof(i=15/2) => sizeof(i=7)=> sizeof(int) = 2 [since i is an integer, it ll store only the integer part of 15/2 = 7]
next it ll print the i value of 5
So o/p is 2 2 5
- 10 years agoHelpfull: Yes(20) No(0)
- Output : 4t4t5
checked on dev c++ - 10 years agoHelpfull: Yes(3) No(0)
- Answer: 2 2 5
sizeof(!d) => sizeof(!5.2) => sizeof(int) = 2 [since 0 is an integer]
sizeof(i=15/2) => sizeof(i=7)=> sizeof(int) = 2
i value of 5
So Answer is is 2 2 5 - 10 years agoHelpfull: Yes(2) No(0)
- o/p=2t2t5
inside sizeof() no operation get evaluated.........
that why i value will remain same.
- 10 years agoHelpfull: Yes(2) No(0)
- Output : 2t2t5
sizeof(!d) => sizeof(!5.2) => sizeof(0) => sizeof(int) = 2 [since 0 is an integer]
sizeof(i=15/2) => sizeof(i=7)=> sizeof(int) = 2 [since i is an integer, it ll store only the integer part of 15/2 = 7]
next it ll print the i value of 5
So o/p is 2t2t5 - 10 years agoHelpfull: Yes(1) No(0)
- 2 2 7
........... - 10 years agoHelpfull: Yes(0) No(2)
- 4 4 5
double=4
int in unix system =4
and i=5 - 10 years agoHelpfull: Yes(0) No(0)
- 2 2 5
here sizeof(i=15/2) here i scope will be within the size of opeartor outside i will be agin 5 - 10 years agoHelpfull: Yes(0) No(0)
- 445
because the ! converts it into int..and the rest is obvious
- 10 years agoHelpfull: Yes(0) No(0)
- Output : 2 2 5
- 9 years agoHelpfull: Yes(0) No(0)
- 2t2t5 OR 4t4t5
depends on compiler - 5 years agoHelpfull: Yes(0) No(0)
- its output will be 4t4t5
because sizeof(!5.2)= sizeof(0)=sizeof(int)=4 and also 't' because only %d is format specifier and t is like a string. similarly sizeof(i=15/2)=sizeof(i=7) here 15/2 is 7 because i is int so sizeof(int)=4 and also t.
& printf("%d",i)=5 because sizeof operator not changes original value of i - 5 years agoHelpfull: Yes(0) No(0)
- output: 1t4t5
- 5 years agoHelpfull: Yes(0) No(0)
TCS Other Question