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; }
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;
}
Solution
The code you provided is not correct. It has a syntax error. The if
statement is not complete. It should have a condition and a block of code to execute when the condition is true. The corrected code should look like this:
#include<stdio.h>
int main()
{
int i=10;
if (i > 10){
// some code here
}
else
{
printf ( "Hello Cocaine!" );
}
return 0;
}
In this corrected code, the printf
statement will execute because the condition in the if
statement (i > 10)
is not true (since i
is equal to 10
, not greater than 10
). So, the output of this program will be: Hello Cocaine!
.
Similar Questions
What will be the output of the C program? ans.09119011 Previous Marked for Review Next
What will be the output of the following program?while i < 20: print(i) i += 1
What will be the output of the following program in Python?print( 2 >3 and 4< 2)
what will be the output of the following program segment: int x=3, y = 17; cout << x/y <<y/x << (y/x) + (x % y);
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; }
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.