C Programming - Control Instructions - Discussion
Discussion Forum : Control Instructions - Point Out Correct Statements (Q.No. 8)
8.
Which of the following statements are correct about the below program?
#include<stdio.h>
int main()
{
int n = 0, y = 1;
y == 1 ? n=0 : n=1;
if(n)
printf("Yes\n");
else
printf("No\n");
return 0;
}
Discussion:
22 comments Page 3 of 3.
Praween kumar said:
7 years ago
y==1?n=0:n=1; <=> (y==1?n=0:n)=1;
Here, within parenthesis is an expression so, we can't assign value in an expression.
Here, within parenthesis is an expression so, we can't assign value in an expression.
(1)
Rajesh katta said:
6 years ago
Here the ternary operator is used so that it will need the left-hand side value like in the form of ternary syntax.
Post your comments here:
Quick links
Quantitative Aptitude
Verbal (English)
Reasoning
Programming
Interview
Placement Papers