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; } None of the above No output [error] expected ‘;’ before ‘else’ 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; } None of the above
No output
[error] expected ‘;’ before ‘else’
Hello Cocaine!
Solution
The output of the program will be "[error] expected ‘;’ before ‘else’". This is because the 'if' statement is not followed by any statement or block of code. In C programming, 'if' must always be followed by a statement or block of code. If there is no statement to execute, it should be followed by a semicolon (;) to indicate an empty statement.
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.