What will be the output of the following program? #include<stdio.h> int main() { int i=10; if (i > 10) else printf ( "Hello Cocaine!" ); return 0; } ans. [error] expected ‘;’ before ‘else’ No output None of the above Hello Cocaine!
Question
What will be the output of the following program? #include<stdio.h>
int main()
{ int i=10; if (i > 10) else printf ( "Hello Cocaine!" );
return 0; }
ans. [error] expected ‘;’ before ‘else’
No output
None of the above
Hello Cocaine!
Solution
The correct answer is "[error] expected ‘;’ before ‘else’". The reason is that the 'if' statement is not complete. In C programming, 'if' must be followed by a condition and then by a statement or a block of statements enclosed in curly braces. Here, there is no statement following the 'if' condition, hence the error.
Similar Questions
What is the output of the following C Program?
What will be the output of the following code?
what will be the output of the c program?
What will be the output of the following C++ code?
What will be the output of the following program?Note: This question helps in clearing the AMCAT exam
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.