Featured
- Get link
- X
- Other Apps
C program to sum the even and odd numbers in an integer array
#include<iostream.h>
#include<conio.h>
void main()
{
clrscr();
int arr[10];int sume=0,sumo=0;
for(int i=0;i<10;i++)
{
cout<<"\nEnter No."<<i+1<<"\n";
cin>>arr[i];
if(arr[i]%2==0)
sume+=arr[i];
else
sumo+=arr[i];
}
cout<<"You Entered \n";
for(i=0;i<10;i++)
{
cout<<arr[i]<<"\t";
}
cout<<"\nSum of even numbers in array "<<sume<<"\n";
cout<<"\nSum of odd numbers in array "<<sumo<<"\n";
getch();
}
OUTPUT:
#include<conio.h>
void main()
{
clrscr();
int arr[10];int sume=0,sumo=0;
for(int i=0;i<10;i++)
{
cout<<"\nEnter No."<<i+1<<"\n";
cin>>arr[i];
if(arr[i]%2==0)
sume+=arr[i];
else
sumo+=arr[i];
}
cout<<"You Entered \n";
for(i=0;i<10;i++)
{
cout<<arr[i]<<"\t";
}
cout<<"\nSum of even numbers in array "<<sume<<"\n";
cout<<"\nSum of odd numbers in array "<<sumo<<"\n";
getch();
}
OUTPUT:
- Get link
- X
- Other Apps
Popular Posts
C++ program to display numbers which get reversed after multiplying by 4
- Get link
- X
- Other Apps
Comments
Post a Comment