Knowee
Questions
Features
Study Tools

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!

🧐 Not the exact question you are looking for?Go ask a question

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

1/4

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.