YouTip LogoYouTip

C Examples Sum Array

# C Example - Sum of Array Elements [![Image 3: C Example](#) C Example](#) Use a for loop to iterate through the output elements and sum them up: ## Example #includeint main(){int array = {1, 2, 3, 4, 5, 6, 7, 8, 9, 0}; int sum, loop; sum = 0; for(loop = 9; loop>= 0; loop--){sum = sum + array; }printf("Sum of elements: %d", sum); return 0; } The output is: Sum of elements: 45 [![Image 4: C Example](#) C Example](#)
← C Examples Copy ArrayC Examples Table Style β†’