Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Write a C program, in the main function, you need to create an integer array wit

ID: 3759116 • Letter: W

Question

Write a C program, in the main function, you need to create an integer array with 10 elements in it. Use a for loop to read 10 integers from the user and store the values to the array (in the order of input). For example (in the screen shot below) the element with index 0 stores 23, the element with index 1 stores value of 55, the element with index 2 stores the value of 87 and so on.

So, CAWindowssystem32cmd.exe Enter 10 intege FU a ues. . . Value 1 : 23 Value 2 : 55 alue 3: 87 alue 4: -12 alue 5: B alue 6: 98 alue 7: 34 alue g: 28 alue 9: -39 alue 10:20 he index for the maximun is 5. Press any key to continue. . . .

Explanation / Answer

#include <stdio.h>
int max_index(int a[], int n);
int main()
{
int a[10],i,j,ind;
for(i=0;i<10;i++)
{
printf("enter the %d element ",i+1);
scanf("%d",&a[i]);
}
ind = max_index(a,10);
printf("Index of the largest value = %d ",ind);
}
int max_index(int a[], int n)
{
int max = a[0];//assign first as max
int i,res = 0;// asiign 0 to result
for(i=0;i<n;i++)
{
if(a[i]>max)
{
max= a[i];//update max
res = i;//update reult
}
}
return res;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote