TCS
Company
Programming
Arrays
Predict the output of following code:
main()
{
int x,a=10;
x=a==10?printf("hait"):printf("hellon");
printf("%d",x);
}
1.hai 4
2. Error
3. hello 3
4. hai hello
Read Solution (Total 12)
-
- hait4
because 1st hait will b printed and then no. of chracaters ie 4 - 6 years agoHelpfull: Yes(8) No(0)
- 1.hait4 first evaluate comparision operator it prints hait and x becomes 4 then 4 is printed
- 6 years agoHelpfull: Yes(2) No(6)
- hait,4 as a=10,then x=a=10...so 10==10...which is true..so it will print the if part and and finally print the the number of words in the printf statement
- 6 years agoHelpfull: Yes(1) No(0)
- ans is hait4
- 6 years agoHelpfull: Yes(0) No(4)
- the condition is true so it takes the Expression 1 and the number of character is 4 so
The result is hai 4 - 6 years agoHelpfull: Yes(0) No(2)
- hait4 -it prints the if part because a is equal to 10,then no. of characters is 4
- 5 years agoHelpfull: Yes(0) No(0)
- Hait4 is the out put...
Because a == 10 is true so x = 1 when x is true hait is printed... - 5 years agoHelpfull: Yes(0) No(0)
- error...because there is only integers assigned to 10..ans hait 10
- 5 years agoHelpfull: Yes(0) No(2)
- ans is hait4
- 5 years agoHelpfull: Yes(0) No(0)
- Return is not present
Ans: Error - 4 years agoHelpfull: Yes(0) No(0)
- hait4
because pritnf print hait and count character then assigned to x which print 4 - 4 years agoHelpfull: Yes(0) No(0)
- hait4 bcz x,a=10, so x=a==10 is also true so it print hait first then print no.of wordsin hait fron the statement print("%d",x)
- 3 years agoHelpfull: Yes(0) No(1)
TCS Other Question