Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR C

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

//C program to find Smallest among four numbers using Conditional or ternary operator

#include<stdio.h>

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

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

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

 //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
8+9 =