Write a program that reads a set of integers, and then finds and prints the sum
of the even and odd integers.
#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;
}
Comments
Leave a comment