C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - Point Out Correct Statements (Q.No. 3)
3.
Which of the following statements are correct about the program?
#include<stdio.h>
int main()
{
int x = 30, y = 40;
if(x == y)
printf("x is equal to y\n");
else if(x > y)
printf("x is greater than y\n");
else if(x < y)
printf("x is less than y\n")
return 0;
}
Answer: Option
Explanation:
This program will result in error "Statement missing ;"
printf("x is less than y\n") here ; should be added to the end of this statement.
Discussion:
8 comments Page 1 of 1.
Traian said:
5 years ago
The only error I get compiling this code is "Syntax error"-because of the missing semicolon.
Otherwise the program works and generates output, can anyone explain why? Is it because of the compiler or?
Otherwise the program works and generates output, can anyone explain why? Is it because of the compiler or?
Natasha said:
6 years ago
Aws per my knowledge, There is no else statement at last. Then how it is?
Chandramani said:
8 years ago
In this question, "semicolon" at the end of the "else if" statement is missing. Also "else" statement is missing.
Abhayraj SN said:
8 years ago
@Unknown. You are right.
NESTED IF ELSE statement should be terminated with ELSE statement.
Correct it if I'm wrong.
NESTED IF ELSE statement should be terminated with ELSE statement.
Correct it if I'm wrong.
Unknown said:
9 years ago
Else statement also missing after else if.
Swaty said:
1 decade ago
Shall we write a program using else-if ladder without using else statement? Anyone Please explain.
Thanks in advance.
Thanks in advance.
Harshit Shrivastava said:
1 decade ago
It will result in a compilation error stating "statement missing" as the semicolon is missing after the statement with the last else-if.
Kamal said:
1 decade ago
Semi colon is required in the end of the statement it is missing so the statement missing error is coming.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers