Here is an optimized program to find the largest and smallest among three entered numbers.
Logic : The entered three numbers N1, N2, N3 are compared in such an order, where the first comparison checks if N1 largest. If so, prints it out and exists; if not so, it omits N1 from further comparison and checks with N2 and N3 only. The same logic but with complement operator, the program finds the least among the three.
The program needs to include the standard IO library, “stdio.h”
int n1, n2, n3;
printf(“\n\n\t ENTER THREE NUMBERS A,B,C…(separated by commas): “);
scanf(“%d,%d,%d”, &n1, &n2, &n3);
printf(“\n\n\t THE BIGGEST NUMBER IS…: “);
if( (n1 > n2) && (n1 > n3) )
else if(n2 > n3)
printf(“\n\n\t THE SMALlEST NMBER IS…: “);
if( (n1 < n2) && (n1 < n3) )
else if(n2 < n3)