Create a C program that accepts 3 integers and display separately the highest and the lowest among them.
   Sample Run:
   Enter 3 integers: 36 54 45
   Highest: 54
   Lowest: 36
#include<stdio.h>
int main(){
printf("Enter 3 integers:Â Â ");
int first;
scanf("%d", &first);
int second;
scanf("%d", &second);
int third;
scanf("%d", &third);
int max = first;
if(second > first && second >third){
max = second;
}
else if(third>second && third>first){
max = third;
}
int min = first;
if(second < first && second <third){
min = second;
}
else if(third<second && third<first){
min = third;
}
printf("\nHighest:Â %d\n", max);
printf("Lowest:Â %d", min);
}
Comments
Leave a comment