C++ Program to print first n odd numbers in descending order


In this program, You will learn how to print first n odd numbers in descending order in C++.


5th => 9 7 5 3 1


Example: How to print first n odd numbers in descending order in C++

Run it Now
#include<iostream>
using namespace std;

int main() {

    int n, i, a;

    cout << "Enter a Number :";
    cin>>n;

    cout << "\nList is :";
    for (i = n - 1; i >= 0; i--) {
        a = 1 + i * 2;
        cout << a << " ";
    }

    return 0;
}

Output:

Enter a Number :10
List is :19 17 15 13 11 9 7 5 3 1