#include<stdio.h>
void main()
{
int i ;
int arr [4];
int sum=o;
for (i=0; i<=4; i++)
{
printf (“enter %d element \n”, i+1);
scanf (“%d”, &arr[i]);
}
for (i=0; i<=4; i++)
{
sum = sum + a[i];
}
printf (“the sum of is %d”, sum);
}
Enter a value for arr[0] =5
Enter a value for arr[1] =10
Enter a value for arr[2] =15
Enter a value for arr[3] =20
The sum is 50
.
You didn't ask a question.
However, clearly the issue is that you're going out of bounds.
arr[4] has 4 indices, but they are 0 to n -1, so arr[0], arr[1], arr[2], arr[3].
Not 4 itself.
Also, in both C and C++, main should return int, not void.
The for loops at lines 7 and 12 are making the array go out of bounds, you are trying to write/read 5 elements in a 4 element array: for (i = 0; i < 4; i++)
Line 6, 0 (zero), not o. o is an undefined variable.
Line 14, did you mean arr[i]? a[i] is an undefined array.
Your quotes (") are some weird typographic quotes, not plain text file quotes.