int avg(int *p);
int main()
{
int i, average, mark[5];
int arr[5];
for(i = 0; i < 5; i++);
{
arr[i] = scanf_s("%d\n", &mark[i]);
}
average = avg(arr);
}
int avg(int *p)
{
int j, total = 0, avg;
for(j = 0; j < 5; j++)
{
total += p[j];
}
avg = total / 5;
return avg;
}
This program did not cause any errors.But while running I am getting "Run-Time Check Failure #2 -stack around the variable "mark" was corrupted. Can some one please explain the reason behind this?
forinmain.