Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

c program to find minimum of 5 numbers using conditional operator in c

//C program to find Smallest among five numbers using ternary operator

#include<stdio.h>

void main()
{
  // Variable declaration
   int a,b,c,d,e,small;

   printf("Enter five number
");
   scanf("%d %d %d %d %d",&a,&b, &c, &d, &e);

 // Smallest among a, b, c and d
   small = ( (a<b && a<c && a<d && a<e) ? a : (b<c && b<d && b<e) ? b : (c<d && c<e)? c : (d<e)? d : e );

 //Display Smallest number
   printf("Smallest Number is : %d",small);

}
Source by cstutorialpoint.com #
 
PREVIOUS NEXT
Tagged: #program #find #minimum #numbers #conditional #operator
ADD COMMENT
Topic
Name
9+9 =