Problem with array in C (to find the biggest of n).
C / C++ / MFC
1
Posts
1
Posters
0
Views
1
Watching
-
i have tried to debug it and found that after 3 inputs it breaks and calls it segmentation problem. Here is the code.
#include
#includeint main(){
int num\[50\], i, j; int count = 0; printf("Enter your integer: \\n"); do{ scanf("%d", num\[i\]); i++; count++; }while(num\[i\]!=0); for(j=1; j<= count; j++){ if(num\[1\] > num\[j\]){ num\[1\] = num\[j\]; } } printf("%d is the greatest of them all !", num\[0\]); return 0;
}