TCS
Company
Programming
Output
Predict the output of following code:
main()
{
if(1) // True always
printf(“hai”);
else
printf(“hello”);
}
1. Error
2. hai
3. hello
4. No output
Read Solution (Total 3)
-
- hai
Here the if statement is always true.thus if block gets executed - 6 years agoHelpfull: Yes(2) No(0)
- we know that o is false and 1 is true. so coming to the main point the condition is:
if(1)
means if it is true
then print" hai " or else the "hello"
so the answer is option (2) hai - 6 years agoHelpfull: Yes(0) No(0)
- here,
As shown that the if statement is always true so after the compilation the output displayed will be
2. - hai - 6 years agoHelpfull: Yes(0) No(0)
TCS Other Question