C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - Point Out Errors (Q.No. 9)
9.
Point out the error, if any in the program.
#include<stdio.h>
int main()
{
int a = 10, b;
a >=5 ? b=100: b=200;
printf("%d\n", b);
return 0;
}
Answer: Option
Explanation:
Variable b is not assigned.
It should be like:
b = a >= 5 ? 100 : 200;
Discussion:
34 comments Page 4 of 4.
Naveen said:
10 years ago
Explain this logic:
c = 0.
b = a%10;
c = c+b;
a = a/10;
c = 0.
b = a%10;
c = c+b;
a = a/10;
Sandy said:
1 decade ago
It gives output as 100 when executed on DEV C++.
Ankit said:
1 decade ago
Still I don't understood.
Rajat Rahul said:
1 decade ago
Mani is correct.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers