C Programming - Expressions - Discussion
Discussion Forum : Expressions - Find Output of Program (Q.No. 13)
13.
What will be the output of the program?
#include<stdio.h>
int main()
{
int k, num=30;
k = (num>5 ? (num <=10 ? 100 : 200): 500);
printf("%d\n", num);
return 0;
}
Answer: Option
Explanation:
Step 1: int k, num=30; here variable k and num are declared as an integer type and variable num is initialized to '30'.
Step 2: k = (num>5 ? (num <=10 ? 100 : 200): 500); This statement does not affect the output of the program. Because we are going to print the variable num in the next statement. So, we skip this statement.
Step 3: printf("%d\n", num); It prints the value of variable num '30'
Step 3: Hence the output of the program is '30'
Discussion:
27 comments Page 3 of 3.
Princess said:
4 years ago
I want ask a doubt; plz explain me.
num =5.
num=num.
print(num).
num =5.
num=num.
print(num).
Punam solanki said:
1 year ago
Anyone, Explain the K variable condition?
Satish said:
1 decade ago
Can you elobrate your answer please.
Sweety said:
8 years ago
I think 200 is the correct answer.
(2)
Puneeth said:
6 years ago
If we print k what is the answer.
(3)
Krishna said:
1 decade ago
What does '?' mark implies here?
Thirupathi said:
1 decade ago
Can you explain in easy manner?
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers