C++ code to print even series

This program will print the even series. For example, if you have entered 12 then it will print all the even numbers which comes between 1 to 12.

#include
#include
void main()
{
int i,n;
clrscr();
cout<<"Enter the value of n:";
cin>>n;
cout<<"nThe even series is:nn";
for(i=0;i<=n;i=i+2)
{
cout<}
getch();
}

Output:

Enter the value of n: 8

The even series is:

0,2,4,6,8

Add Comment