So I have this code where I make the user enter between how many numbers does thy want to make the comparation:
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
int main(void){
int n;
int x;
int numbers[n];
int count;
printf("Mitme arvu vahel soovite võrdlust sooritada?: ");
scanf("%d",&n);
printf("Soovisite võrdlust teostada %d arvu vahel\n",n);
printf("Sisestage palun arvud: \n");
for (count = 1; count <= n; count++ ){
printf("Arv %d:",count);
scanf("%d",&numbers[n]);
}
for (count = 0; count <= n; count++){
if (numbers[count] > x){
x = numbers[count];
}
}
printf("%d\n",x);
return 0;
}
Now the problem with it is that when the final printf is made, I get somesort of unrealistic number.
This is the output when I make the n 3:
./ComparingC Mitme arvu vahel soovite võrdlust sooritada?: 3
Soovisite võrdlust teostada 3 arvu vahel
Sisestage palun arvud:
Arv 1:1
Arv 2:2
Arv 3:3
4196269
The number at the end is what I am talking about. It should show the biggest number amongst all of the other number but right now it showing something out of the deep space it seems.
EDIT: Also when I make the n equal 5 and enter 1 as the first number, the program ends right there?