I know this is a basic problem, but I don't know C that well and my teacher doesn't teach and I thought maybe stack overflow can help me out and teach me. Especially since I have an exam coming up and most likely this concept will be on the exam. I am clueless.
And this is my code:
#include <stdio.h>
#define ARRSIZE 6
int main() {
int arrOfInt[ARRSIZE] = {19, 51, 23, 6, 79, 95};
int i;
int min;
int INT_MIN;
min = INT_MIN;
for (i = 0; i < ARRSIZE; i++) {
if(arrOfInt[i] < min) {
min = arrOfInt[i];
}
}
}
printf("Minimum is: %d\n", min);
return 0;
}
I got started and probably did it wrong, but I don't know what to do next.
Also he said "write it from scratch" and I don't know what that means. I'm assuming he means no libraries or anything like that? I'm not entirely sure but I'm assuming what I'm doing is "from scratch."
Also if you don't want to tell me how to do the max number because you're afraid of giving me the answer, then that's fine you don't have to because once I know how to do this for the minimum, I'll know how to do it for the max and will be able to do it on my own (I think.)
Thank you, any help would be appreciated!
EDIT: So I'll make it more clear and edit the code a bit. I guess this question will turn into me asking how to fix a series of errors.
I fixed the code a bit and I'm left with this error:
main.c:5:29: error: expected expression before ‘[’ token int arrOfInt[ARRSIZE] = [19, 51, 23, 6, 79, 95];
EDIT 2: The error is fixed but now it outputs nothing.
EDIT 3: It inputs something but it only inputs 0. I decided to change the i = 0 to i = 100 but it didn't work.