I wrote this program and I need to know if I didn't make a mistake
Let arr be an array of 20 integers. Write a program that first fill the array with up to 20 input values and then finds and displays both the subscript of thee largest item in arr and the value of the largest item.
/* 181415.c */
#include <stdio.h>
void main() {
int arr[20]; /* define an array of 20 integers */
int i;
int max;
int max_index;
// Input 20 integers
printf("Input 20 integers: \n");
for (i = 0; i < 20; i++) {
printf("Integer %d: ", i);
scanf("%d", &arr[i]);
}
// Find the largest integer and its index
max = arr[0];
max_index = 0;
for (i = 1; i < 20; i++) {
if (arr[i] > max) {
max = arr[i];
max_index = i;
}
}
// Print out the max integer and its index
printf("The largest integer is %d\n", max);
printf("Its position is at index %d\n", max_index);
getchar();
}