Skip to main content

Featured

functions in Python

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:

Comments

Popular Posts