Answer:
// here is code in C
#include <stdio.h>
// main function
int main(void) {
// variables
int a,b,c;
int mx,mn;
printf("Enter three numbers: ");
// read the 3 numbers
scanf("%d %d %d",&a,&b,&c);
// if all are not different
if(a==b||a==c||b==c)
{
printf("all numbers are not different:");
}
// find the largest
else{
if(a>b)
{
if(a>c)
mx=a;
else
mx=c;
}
else{
if(b>c)
mx=b;
else
mx=c;
}
// find the smallest
if(a<b)
{
if(a<c)
mn=a;
else
mn=c;
}
else{
if(b<c)
mn=b;
else
mn=c;
}
}
// print largest and smallest
printf("largest of all is: %d \n",mx);
printf("smallest of all is: %d",mn);
return 0;
}
Explanation:
Read three numbers and assign them to variables "a","b" and "c" respectively. Check if all the numbers are different or not.If all are not different then print message "all are not different.".Otherwise find the largest and assign to "mx" and then find the smallest and assign to "mn".Print the largest and smallest of all three.
Output:
Enter three numbers:5 2 9
largest of all is: 9
smallest of all is: 2