TCS
Company
Programming
Database
Output of following program?
#include
int main()
{
printf("%d", printf("%d", printf(ā%dā,543210)));
return 0;
}
1. 54321061
2. 543210
3. 5432101
4. 5432106
Read Solution (Total 13)
-
- Answer is 543210.
Actually printf statement executed from right to left so first innermost printf will be executed 543210, then second printf will printf no of characters it has read ie 6 and the outermost printf will print 1 so the answer will be 54321061 - 6 years agoHelpfull: Yes(12) No(8)
- 1.54321061
- 6 years agoHelpfull: Yes(6) No(2)
- 1.54321061
Bcz firstly print total number of digits =6
Then for next printf previous and total number of digits =61
So ans is = 1.54321061 - 6 years agoHelpfull: Yes(4) No(0)
- 54321061
first pf print number ,second pf printf total didgits in there 6,third also total digit in there 1 - 6 years agoHelpfull: Yes(2) No(0)
- 54321061
printf("%d", printf("%d", printf(ā%dā,543210)));
|
prints 543210 and returns count of digits as 6
this one prints 6 and returns 1 count of digits
this one prints 1
final answer 54321061 - 6 years agoHelpfull: Yes(1) No(0)
- OPTION 1.54321061
- 5 years agoHelpfull: Yes(1) No(0)
- Ans- option 1
- 6 years agoHelpfull: Yes(0) No(1)
- Option 4.why because printf statement first print the values then next printf count the no.of digits
- 6 years agoHelpfull: Yes(0) No(0)
- OPTION 1.54321061
- 6 years agoHelpfull: Yes(0) No(0)
- As we know printf is a function with int as return type,it returns the number of characters printed.So it firsts prints the number 543210 and returns 6 and prints 6 and returns 1 and prints 1.
so answer is option 1.54321061 - 6 years agoHelpfull: Yes(0) No(0)
- Then execution in turbo c gives 1892251.. I think this question may be wrong
- 6 years agoHelpfull: Yes(0) No(1)
- 543210 because it is nested printf syntax
- 6 years agoHelpfull: Yes(0) No(1)
- if third printf should have "" then answer will have 54321061
- 5 years agoHelpfull: Yes(0) No(0)
TCS Other Question