TCS
Company
Programming
Program
Output of following program?
#include
int main()
{
printf("%d", printf("%d", 1234));
return 0;
}
1. 12344
2. 12341
3. 11234
4. 41234
Read Solution (Total 18)
-
- first it will print "1234"
printf() function will return the no. of charecters printed i.e, 4.
hence the output will be "12344". - 6 years agoHelpfull: Yes(9) No(0)
- 1.12344 printf return successfully read char number
- 6 years agoHelpfull: Yes(2) No(0)
- the answer is 12344.
think it like this....
int x = printf("%d",1234); //first printf will print 1234 and then x will be 4, because printf return the number of char it printed
printf("%d",x);
so the answer 12344 - 6 years agoHelpfull: Yes(2) No(0)
- 1.12344 printf() function always return the number of character it successfully printed.
so,first the inner printf print the 1234 and its return 4 to the outer printf and outer printf print 4 .
answer will be 12344 - 6 years agoHelpfull: Yes(1) No(0)
- ans 12344
- 6 years agoHelpfull: Yes(0) No(0)
- from ri8 to left execution will take place...hence 1234 and thn no. of characters in 1234 ie 4 will b print hence ans is 12344
- 6 years agoHelpfull: Yes(0) No(0)
- Option 1 because first print the statement as it is and then count the digits and print it
- 6 years agoHelpfull: Yes(0) No(0)
- No, all the options are wrong.Because they didn't complete the header file then it shows error.
- 6 years agoHelpfull: Yes(0) No(0)
- 12341(first printf=1234 & second printf =12341)
- 6 years agoHelpfull: Yes(0) No(0)
- 12344 it is right ans
- 6 years agoHelpfull: Yes(0) No(0)
- printf function returns number of characters ahd hence the output will be "12344"
- 6 years agoHelpfull: Yes(0) No(0)
- the answer is "a"
12344 - 6 years agoHelpfull: Yes(0) No(0)
- first print 1234 and then as it have print 4 numbers so 12344
- 6 years agoHelpfull: Yes(0) No(0)
- 12344 is answer.. bcz printf statement in nested form and in prints right to left. first inner printf prints 1234 and outer print stmnt print no.of digits 4.finnally o/p is 12344.
- 6 years agoHelpfull: Yes(0) No(0)
- 12344
as print returns the length of integer so
1st it prints 1234 then its length i.e, 4
12344 - 5 years agoHelpfull: Yes(0) No(0)
- 2
first inner printf("%d",1234) then the outer printf gets executed printf returns 1.So 12341 - 5 years agoHelpfull: Yes(0) No(0)
- 1
printf return successfully read char number - 5 years agoHelpfull: Yes(0) No(0)
- first print " 1234"
then return count the digit 4
hence the output will be " 12344" - 5 years agoHelpfull: Yes(0) No(0)
TCS Other Question