Tue Jun 05 2018

Array Sum

C Programming2642 views

File Name: array-elements-sum.c

#include<stdio.h>

int main() {

	/* Declaration of integer type array and initialize with 10 values */
	int array[ ] = {1,2,3,4,5,6,7,8,9,10};
	int ans = 0, i;
	for(i = 0; i < 10; i++)
		ans += array[i];
	printf("Sum of Array: %d\n",ans);
	return 0;
}



/* Output */
Sum of Array: 55
Reference:

We use cookies to improve your experience on our site and to show you personalised advertising. Please read our cookie policy and privacy policy.