Navigation Bar

Print the sequence of all Odd 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 Odd Numbers Between "<<a<<" & "<<b<<" is\n";
while (a<=b)
{
if (a!=0 && a%2!=0)
cout<<a<<" ";
a++;
}
getch();
}

Output


Enter Starting Limit: 2
Enter ending Limit: 10
All Even Numbers Between 2 & 10 is
3 5 7 9

No comments:

Post a Comment