Jump to content

To find minimum of three numbers using ternary (conditional) operator

From IdeaWazaWiki
Revision as of 11:51, 19 December 2006 by wikademia>Milan (New page: <pre>→To find minimum of three numbers using ternary (conditional) operator: #include <stdio.h> #include <conio.h> void main() { int a,b,c,temp,min; clrscr(); printf ("\n\n Enter t...)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
/* To find minimum of three numbers using ternary (conditional) operator*/
#include <stdio.h>
#include <conio.h>

void main()
{
	int a,b,c,temp,min;
	clrscr();

	printf ("\n\n Enter three nos. one after the other: ");
	scanf ("%d%d%d", &a, &b, &c);

	temp = (a<b)? a:b;
	min = (c<temp)? c:temp;

	printf ("\n\n The Minimum of the three is: %d", min);
	getch();
}
/* Output:


 Enter three nos. one after the other: 2 5 9


 The Minimum of the three is: 2
*/