prev


Ternary Operator

31. Smallest of three numbers(Nested Ternary Operator)(11.7.2009)

/*
Program# 31
date : 25-12-2008
Smallest of three numbers
*/

#include <stdio.h>
main(){
int a,b,c,d;
printf("\nEnter three integers :");
scanf("%d %d %d",&a,&b,&c);
d=(a<b)?((a<c)?a:c):((b<c)?b:c);
printf("\n%d :Smallest number\n",d);
}

output:

$ gcc p31.c
$ ./a.out

Enter three integers :12 34 3

3 : Smallest number
$

next
blog comments powered by Disqus