-2
#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;
}
Dmitry Bychenko
  • 165,109
  • 17
  • 150
  • 199

1 Answers1

0

The ?: operator doesn't quite work like that. What you want to do is something like:

n = ((y == 1) ? 0 : 1);

In the more general case, if you want to perform actions based on a condition, use an if. The ?: operator is more for returning values based on the condition.

Steve
  • 1,735
  • 9
  • 18