Monday, 6 August 2018

Sum of odd and even nos.

===========================================================================
                                CODING



#include<all.h>

void main()
{
    clrscr();
    int n,i,n1,q,SUM=0,sum=0;
    cout<<"\nEnter how many numbers you want to Enter: ";
    cin>>n;
    cout<<"\n";
    for(i=1;i<=n;i++)
    {
       cout<<"\nEnter number "<<i<<": ";
       cin>>n1;
       if(n1%2==0)
       SUM=n1+SUM;
       else
       sum=sum+n1;
    }
    cout<<"\n\nThe Sum of all Even numbers is: "<<SUM;
    cout<<"\n\nThe Sum of all Odd numbers is: "<<sum;
    getch();
}




===========================================================================


                                OUTPUT


No comments:

Post a Comment