C Program to Add Elements of an Array

C Program to Add Elements of an Array

Write C Program to Add Elements of an Array

// C Program to Add Elements of an Array

#include <stdio.h>

int main()
{
	int A[5];
	int i, sum = 0;

	for(i = 0; i < 5; i++)
	{
		printf("Enter A[%d] :--> ", i);
		scanf("%d", &A[i]);

		sum = sum + A[i];
	}

		printf("The sum of the array elements is :--> %d",sum);

	return 0;
}

Output:

Enter A[0] :--> 1
Enter A[1] :--> 2
Enter A[2] :--> 3
Enter A[3] :--> 4
Enter A[4] :--> 5

The sum of the array elements is :--> 15