Answer the question
In order to leave comments, you need to log in
Why does the program (search for the minimum and maximum in the array) not work?
Here is the program itself. Please do not swear, I'm just starting to learn programming.
int N = 5, A[N], i;
for(i = 0; i < N; i++){
printf("Enter A[%d]\n", i);
scanf("%d", &A[i]);
}
printf("\nNumber of element\tValue\n");
for(i = 0; i < N; i++){
printf("A[%d]\t\t\t%d\n", i, A[i]);
}
int min = A[0], max = A[0];
for(i = 0; i < N; i++){
if(A[i] < min) min = A[i];
if(A[i] > max) max = A[i];
}
printf("min = %d\nmax = %d");
Answer the question
In order to leave comments, you need to log in
#include <stdio.h>
void main() {
int N = 5, A[N], i;
for(i = 0; i < N; i++){
printf("Enter A[%d]\n", i);
scanf("%d", &A[i]);
}
printf("\nNumber of element\tValue\n");
for(i = 0; i < N; i++){
printf("A[%d]\t\t\t%d\n", i, A[i]);
}
int min = A[0], max = A[0];
for(i = 0; i < N; i++){
if(A[i] < min) min = A[i];
if(A[i] > max) max = A[i];
}
printf("min = %d\nmax = %d\n", min, max);
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question