Problem 15

author
By Supreme2023-02-26
Problem Statement :
Write a C program to find out the Maximum and Minimum number from given 10 numbers
Code:

#include <stdio.h>

int main(){

printf("\t\tMinimum & Maximum");
printf("\n============================================\n\n");

int a[10],i,min,max;

for(i=0;i<10;i++){
printf("Enter The Number [%d] : ",i+1);
scanf("%d",&a[i]);

if(i==0){
min=max=a[i];
}
else{
if(min>a[i]){
min=a[i];
}
else if(max<a[i]){
max=a[i];
}
}
}
printf("\n_______________________________________________\n\n");
printf("\nMinimum Value Is : %d\n",min);
printf("\nMaximum Value Is : %d",max);
printf("\n\n_______________________________________________\n\n");

return 0;
}

Description :
  • This is a C program that prompts the user to input 10 numbers, then finds the minimum and maximum numbers among them. The program first prints out a header for the output, then declares an integer array a of size 10, and integer variables i, min, and max.
  • Next, the program enters a loop that prompts the user to input 10 numbers one by one, and stores them in the array a. During the loop, the program also updates the variables min and max to keep track of the minimum and maximum numbers seen so far.
  • After the loop is finished, the program prints out the minimum and maximum values found.
Output Image:
Output-image

© Copyright 2022. All right reserved, GTU Coder.