Answer to Question #269969 in C++ for DANISH

Question #269969

Write a program that reads a set of integers, and then finds and prints the sum



of the even and odd integers.

1
Expert's answer
2021-11-22T09:53:43-0500
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
	int count=0,count1=0;
	cout<<"Enter 10 numbers: ";
	for(int i=0;i<10;i++){
		cin>>i;
	if(i%2==0){
			count+=i;
			
		}
		else{
			count1+=i;
			
		}
	 
}
cout<<"Sum of even numbers are: "<<count<<endl;
cout<<"Sum of odd numbers are: "<<count1<<endl;
}

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