Here is a program for begineers also.
It is one of the easiest. It just print two series even and odd upto the no. entered.
#include<iostream.h>
void main()
{
int n;
cout<<"Enter a number\n";
cin>>n;
cout<<"Even Series\n";
for (int i=1;i<=n;i++)
if(i%2==0)
cout<<i<<" ";
cout<<"\nOdd Series\n";
for (i=1;i<=n;i++)
if(i%2==1)
cout<<i<<" ";
}
It is one of the easiest. It just print two series even and odd upto the no. entered.
#include<iostream.h>
void main()
{
int n;
cout<<"Enter a number\n";
cin>>n;
cout<<"Even Series\n";
for (int i=1;i<=n;i++)
if(i%2==0)
cout<<i<<" ";
cout<<"\nOdd Series\n";
for (i=1;i<=n;i++)
if(i%2==1)
cout<<i<<" ";
}
No comments:
Post a Comment