Monday, 8 July 2013

Print Odd number in C++

#include<iostream.h>
#include<conio.h>

void main()
{
    clrscr();
    int a,b;
    cout<<"\nEnter starting range : ";
    cin>>a;
    cout<<"\nEnter ending range : ";
    cin>>b;
    cout<<"\n\n---------------------\n";
    cout<<" Odd Numbers \n";
    cout<<"---------------------\n\n";
    while(a<=b)
    {   
        if(a%2!=0)
            cout<<a<<" ,";
        a++;
    }   
getche() ;
}

No comments:

Post a Comment