Wednesday, 24 July 2013

Even Numbers in Descending Order

// Write a C++ program that prints odd numbers in
// descending order from a given range.

#include<iostream.h>
#include<conio.h>
void main()
{
    clrscr();
    int i,n;
    cout<<"Enter any number : ";
    cin>>n;
   
    cout<<"\n\n------------------------------------\n";
    cout<<" Even numbers in Descending Order \n";
    cout<<"------------------------------------\n";

    if( n%2 != 0 )
    n--;
    for( i = n ; i >= 0 ; i = i-2 )
    cout<<"         "<<i<<endl;
    getch();
}

No comments:

Post a Comment