Showing posts with label odd number in descending order. Show all posts
Showing posts with label odd number in descending order. Show all posts

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();
}