Create a C program that stores 10 integers. Print the maximum and the minimum integer found in the array.
#include<stdio.h>
int main(){
printf("Enter 10 integers\n");
int arr[10];
int i, j, k;
for(i =0 ; i<10; i++){
scanf("%d", &arr[i]);
}
int max = arr[0], min = arr[0];
for(j=0; j<10; j++){
if(arr[j]>max){
max = arr[j];
}
}
for(k=0; k<10; k++){
if(arr[k]<min){
min = arr[k];
}
}
printf("The maximum is %d and minimum is %d", max, min);
}
Comments
Leave a comment