#include<stdio.h>
int main() {
int n, i, max, position;
// Ask user for the number of elements
printf("Enter the number of elements: ");
scanf("%d", &n);
int arr[n];
// Input array elements
printf("Enter %d numbers:\n", n);
for (i = 0; i < n; i++) {
scanf("%d", &arr[i]);
}
// Initialize max and position
max = arr[0];
position = 0;
// Find the maximum and its position
for (i = 1; i < n; i++) { if (arr[i] > max) {
max = arr[i];
position = i;
}
}
// Output the result
printf("The largest number is %d at position %d (index %d).\n", max, position + 1, position);
return 0;
}
OUTPUT
Enter the number of elements: 5
Enter 5 numbers:
10 45 32 67 23
The largest number is 67 at position 4 (index 3).