C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - Find Output of Program (Q.No. 11)
11.
What will be the output of the program?
#include<stdio.h>
int main()
{
int k, num = 30;
k = (num < 10) ? 100 : 200;
printf("%d\n", num);
return 0;
}
Discussion:
39 comments Page 3 of 4.
Varsha said:
5 years ago
If (30<10) 200 is executed. If that statement true means 100 is executed. So the answer is 200.
(1)
Rakesh said:
1 decade ago
Absolutely correct.
We have to read complete question, and first we have to understand logic.
We have to read complete question, and first we have to understand logic.
P.kranthi kumar said:
9 years ago
k = (num<10)?100:200 is become false&
Here print the k, so the answer will become 30.
Here print the k, so the answer will become 30.
Ravi said:
9 years ago
@Meenu.
You explained clearly I clarify my doubt with the help of your explanation, Thanks.
You explained clearly I clarify my doubt with the help of your explanation, Thanks.
Saloni kamboj said:
9 years ago
k = (num < 10) ? 100 : 200;
I am not getting this statement, Please explain it to me.
I am not getting this statement, Please explain it to me.
(2)
Sushant shankar mahadik said:
1 decade ago
k = (num<10) ?100:200 is become false &.
Here print k so answer will be 30.
Here print k so answer will be 30.
Varsha said:
1 decade ago
Thanx Meenu, I was not knowing the meaning of this statement. It really helped me.
Brij said:
1 decade ago
step 1: num = 30
step 2: k = 200
step 3: print the value of num i.e 30;
step 2: k = 200
step 3: print the value of num i.e 30;
Golu said:
1 decade ago
Here if condition is not satisfied so it assumes the garbage value.
Abc said:
1 decade ago
It have the value of num not of k % its 30.
So it will print 30.
So it will print 30.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers