Is nesting of conditional operator( ? : ) possible? If no then why? If yes then write down the program to find the greatest of three number?

Yes, Nesting of conditional operator is possible .Write down the program yourself.

Showing Answers 1 - 3 of 3 Answers

baseersd

  • Oct 31st, 2007
 

Conditional operator can be nested. But it is not recommended as there are chances of getting confuse with its statements.
Here is the code for nesting of conditional operator.

#include <stdio.h>
int main()
{
    int a,b,c;
    int max;
    printf("nEnter the values for a,b,c ");
    scanf("%d%d%d",&a,&b,&c);
   
    max = ( (a > b) && ( a > c)? a : (b >c) ? b : c );
    printf("Max = %d",max);
    getch();
}

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions