Navigation Bar

Print the sequence of all Even numbers



#include<conio.h>
#include<iostream.h>
void main()
{                
   clrscr();
   int a, b;
   cout<<"Enter Starting Limit: ";
   cin>>a;
   cout<<"Enter ending Limit: ";
   cin>>b;
   cout<<"All Even Numbers Between "<<a<<" & "<<b<<" is\n";
   while (a<=b)
{
if (a!=0 && a%2==0)
cout<<a<<" ";
a++;
}
   getch();
}

Output


Enter Starting Limit: 3
Enter ending Limit: 17
All Even Numbers Between 3 & 17 is
4 6 8 10 12 14 16

No comments:

Post a Comment