/*PROGRAM TO FIND SUM OF EVEN AND ODD NUMBERS UPTO N*/
#include<conio.h>
#include<iostream.h>
class sum_evn_odd
{
int n,i,sum1,sum2;
public:
void input();
void output();
};
void sum_evn_odd::input()
{
cout<<“Enter the limit: “;
cin>>n;
}
void sum_evn_odd::output()
{
if(n>0)
{
sum1=0;
sum2=0;
cout<<“Total numbers upto “<<n<<” are:\n”;
for(i=1;i<=n;i++)
{
cout<<i<<” “;
if(i%2==0)
sum1=sum1+i;
else
sum2=sum2+i;
}
cout<<“\nSum of even numbers upto “<<n<<” is: “<<sum1;
cout<<“\nSum of odd numbers upto “<<n<<” is: “<<sum2;
}
else
cout<<“Enter limit in positive terms”;
}
void main()
{
sum_evn_odd s1;
clrscr();
s1.input();
s1.output();
getch();
}