Wednesday 17 July 2013

Odd numbers in descending order

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

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

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


1 comment:

  1. how to print odd numbers in ascending and and the in decending order

    ReplyDelete