C Programming - Expressions - Discussion
Discussion Forum : Expressions - General Questions (Q.No. 3)
3.
Which of the following is the correct usage of conditional operators used in C?
Answer: Option
Explanation:
Option A: assignment statements are always return in paranthesis in the case of conditional operator. It should be a>b? (c=30):(c=40);
Option B: it is syntatically wrong.
Option D: syntatically wrong, it should be return(a>b ? a:b);
Option C: it uses nested conditional operator, this is logic for finding greatest number out of three numbers.
Discussion:
30 comments Page 2 of 3.
Heena said:
1 decade ago
max = a>b ? (a>C ? a : c) : (b>c ? b :c);
Now I guess this statement is more clear.
Now I guess this statement is more clear.
(2)
Mona said:
8 years ago
Option C is also not correct because there is no semi colon in the end of the statement.
(2)
Vishwas Pathak said:
1 decade ago
Option A is also right i did it in the dev-c++ and i got first one as the answer.
Deepa said:
8 years ago
I did not understand the meaning of the operator ":" between the variables.
Merry john said:
1 decade ago
I am agree with @Vishwas and @Azhar. Option A should be correct one.
Pankaj said:
5 months ago
Option C does not end with a semicolon. So option A is correct.
(1)
Reddy said:
8 years ago
C. Also a syntax error because at the semicolon has missed.
(1)
Vinutha said:
1 decade ago
Can any one tell the correct syntax of all operators?
Sankar said:
8 years ago
Here the expression is evaluated from right to left.
(1)
Mahalakshmi said:
10 years ago
I am not understand please explain clearly about it.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers