I came across certain MCQs in some book n some of them are very interestingly unexplainable :-),... at least i couldnt understand them;plz if anyone has explaination for any of them, let me know.
whatever you may write after %.. i mean only 1 more charachter, only % will be the output.. how come?
output for this is 0 1 1
where as when i debugged it, value of i is coming as -1;.
output for this 8,0 ,garbage.. how come 0 and not garbage at second place?
we have to enter a value here, and no matter what value we enter, output is 1 and 3. !!
output to this is very surprisingly 5.. when i checked in help of turbo C, they had given u cant divide any integer by 0, else an error will be generated.
but only a warning had come and answer was 0.
this gave runtime divide error!....
ultimately we are carrying out same thing right?
here the output comes as 8!.... so may be its taking some octet base because for 0101 the value came as 65... a bit explainable.. but for 1010 output comes as 1010 itself...
comment is taken only till computer and if i remove * of computer it will be taken till education; but it takes the farthest one if m not wrong.
Whats the logic behind this?
comes as 8,..but that's the value for double and not for float...
is 4, then how do we deciede which is float and double?
output for this is sun and 3..
I got how 3 came, because sun has 3 charachters in it and i had also done lot many changes in sun and accordingly got answers depending on length of word.. but why that happens.. after inner printf has printed the things; does it returns no. of charachters or sth?
Code:
void main() { printf("%c",'%d'); }
Code:
void main() { int i=1,,j=0,k=i--&&++j||--i; printf("%d%d%d%"i, j,k); }
where as when i debugged it, value of i is coming as -1;.
Code:
void main() { printf("%d%d%d%",8); }
Code:
void main() { int no=3; printf("%d%d",scanf("%c",&no),no); }
Code:
void main() { printf("%d",5/0); }
but only a warning had come and answer was 0.
Code:
void main() { int i=0; printf("%d",5/i); }
ultimately we are carrying out same thing right?
Code:
void main() { printf("%d",010); }
Code:
printf/*("sun*/ computer*/ education");*/
Whats the logic behind this?
Code:
sizeof(3.14)
Code:
sizeof(float)
Code:
printf("%d",printf("sun"));
I got how 3 came, because sun has 3 charachters in it and i had also done lot many changes in sun and accordingly got answers depending on length of word.. but why that happens.. after inner printf has printed the things; does it returns no. of charachters or sth?
Comment