Computer Science, asked by aniruddhsinh11, 2 months ago

What is the output of the C statement.?
void main()
{
int a=0;
a = 5<2 ? 4:3;
printf("%d",a);
getch();
} *​

Answers

Answered by dreamrob
1

Given:

void main()

{

  int a=0;

  a = 5<2 ? 4:3;

  printf("%d",a);

  getch();

}

Output:

3

Explanation:

Ternary operator

variable = condition ? true : false

In this, if the condition is true then the value at place of true will be stored in the variable and if the condition is false then the value at the place of false will be stored.

a = 5<2 ? 4 : 3

5<2 → false, so 3 will be stored in variable a

So, the output is 3

Similar questions