Answer to Question #260656 in C for Them

Question #260656

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


1
Expert's answer
2021-11-03T11:44:06-0400
#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);
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS