10. Write a C program that prints both the Max and Min value in an array
Sat Jul 22 2023 11:12:28 GMT+0000 (Coordinated Universal Time)
Saved by
@Codes
// Online C compiler to run C program online
#include <stdio.h>
int main() {
int points[6] = {5,9,2,4,0,6};
int max = 0;
int min = 0;
for(int i = 0; i < 6; i++){
if(points[i] > max){
max = points[i];
}
}
for(int i = 0; i < 6; i++){
printf("The max is %d", max);
break;
}
for(int i = 0; i < 6; i++){
if(points[i] < min){
min = points[i];
}
}
for(int i = 0; i < 6; i++){
printf("\nThe min is %d", min);
break;
}
return 0;
}
content_copyCOPY
Comments