CS Electrical And Electronics
@cselectricalandelectronics

What is this in c programming? max_num = (a > b) ? (a > c ? a : c) : (b > c ? b : c);

All QuestionsCategory: C LanguageWhat is this in c programming? max_num = (a > b) ? (a > c ? a : c) : (b > c ? b : c);
chetan shidling asked 4 years ago
 max_num = (a > b) ? (a > c ? a : c) : (b > c ? b : c); 

Can anyone explain?
1 Answers
chetan shidling answered 4 years ago

It is nothing but an if-else statement.
 
if(a>b)
     if(a>c)
            printf(“a is greater”);
       else
            printf(“c is greater”);
else
       if(b>c)
             printf(“b is greater”);
       else
            printf(“c is greater”);
 
Is same as
 

max_num = (a > b) ? (a > c ? a : c) : (b > c ? b : c);