Computer Science, asked by hoairwateramer6153, 11 months ago

Write a c program to find biggest of three numbers using ternary operator

Answers

Answered by pavantejancrazy
8

#include<stdio.h>

void main()

{

int a, b, c, big ;

printf("Enter three numbers \n ") ;

scanf("%d %d %d", &a, &b, &c) ;

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

printf(" \n The biggest number is : %d", big) ;

}

Answered by shilpa85475
2

Explanation:

# include <stdio.h>

   int a, b, c, big ;

   printf("Enter three numbers : ") ;

   scanf("%d %d %d", &a, &b, &c) ;

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

   printf("\nThe biggest number is : %d", big) ;

 A ternary operator allows one to assign one value to the variable if the condition is true, and another value if the condition is false.

The if-else block from above could now be written as shown in the example below.

var num = 4, msg = ""; msg = (num === 4)  

Similar questions