Answer to Question #267989 in C for Phn

Question #267989

Mr. Hari has bought 10 items from the shop. He has stored the price of all the items in an array. Help




Mr. Hari to print the sum of the even items in the array

1
Expert's answer
2021-11-18T06:57:38-0500
#include <stdio.h>
#include <stdlib.h>


int main()
{
	int sumEvenItems=0;
	int i;
	int items[]={5,8,9,4,2,3,69,5,6,9};


	for(i=0;i<10;i++){
		if(items[i]%2==0){
			sumEvenItems+=items[i];
		}
	}




	printf("The sum of the even items in the array: %d\n\n",sumEvenItems);


	getchar();
	return 0;


}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS