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


Warning: Trying to access array offset on false in /home3/indiakep/public_html/wp-content/plugins/dw-question-answer/inc/Template.php on line 8
All QuestionsCategory: C LanguageWhat is this in c programming? max_num = (a > b) ? (a > c ? a : c) : (b > c ? b : c);
chetan shidling asked 5 years ago
 max_num = (a > b) ? (a > c ? a : c) : (b > c ? b : c); 

Can anyone explain?
1 Answers
chetan shidling answered 5 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);