C Program to Print First N Natural Numbers in Reverse

C program to print first n natural numbers in reverse; Through this tutorial, we will learn how to print first n (10, 100, 1000 .. N) natural numbers in reverse in the c program with the help for loop, while loop and do-while loop.

Algorithm and Program to Print First N Natural Numbers in Reverse in C

Let’s use the following algorithm and program to print numbers in reverse order using for loop, while loop and do while loop in c:

  • Algorithm to Print First N Natural Numbers in Reverse
  • C Program to Print First N Natural Numbers in Reverse using For Loop
  • C Program to Print First N Natural Numbers in Reverse using While Loop
  • C Program to Print First N Natural Numbers in Reverse using Do While Loop

Algorithm to Print First N Natural Numbers in Reverse

Use the following algorithm to write a program to print first n(10, 100, 1000 .. N) natural numbers in reverse; as follows:

  • Step 1: Start Program.
  • Step 2: Read the a number from user and store it in a variable.
  • Step 3: Print first n natural number in reverse using for loop or while loop or do while loop.
  • Step 4: Stop Program.

C Program to Print First N Natural Numbers in Reverse using For Loop

#include <stdio.h>

int main() {
    int counter, N;
    /*
     * Take a positive number as input form user
     */
    printf("Enter a Positive Number :- ");
    scanf("%d", &N);

    printf("Printing Numbers form %d to 1\n", N);
    /*
     * Initialize the value of counter to N and keep on
     * decrementing it's value in every iteration till
     * counter > 0
     */
    for(counter = N; counter > 0; counter--) {
        printf("%d \n", counter);
    }

    return 0;
} 

The output of the above c program; as follows:

Enter a Positive Number :- 10
Printing Numbers form 10 to 1
10
9
8
7
6
5
4
3
2
1 

C Program to Print First N Natural Numbers in Reverse using While Loop

#include <stdio.h>

int main() {
    int counter, N;
    /*
     * Take a positive number as input form user
     */
    printf("Enter a Positive Number :- ");
    scanf("%d", &N);

    printf("Printing Numbers form %d to 1\n", N);
    /*
     * Initialize the value of counter to N and keep on
     * decrementing it's value in every iteration till
     * counter > 0
     */
    counter = N;
    while(counter > 0) {
        printf("%d \n", counter);
        counter--;
    }

    return 0;
} 

The output of the above c program; as follows:

Printing Numbers form 10 to 1
10
9
8
7
6
5
4
3
2
1

C Program to Print First N Natural Numbers in Reverse using Do While Loop

#include <stdio.h>

int main() {
    int counter, N;
    /*
     * Take a positive number as input form user
     */
    printf("Enter a Positive Number :- ");
    scanf("%d", &N);

    printf("Printing Numbers form %d to 1\n", N);
    /*
     * Initialize the value of counter to N and keep on
     * decrementing it's value in every iteration till
     * counter > 0
     */
    counter = N;
    do {
        printf("%d \n", counter);
        counter--;
    } while(counter > 0);

    return 0;
} 

The output of the above c program; as follows:

Enter a Positive Number :- 10
Printing Numbers form 10 to 1
10
9
8
7
6
5
4
3
2
1 

Recommended C Programs

AuthorDevendra Dode

Greetings, I'm Devendra Dode, a full-stack developer, entrepreneur, and the proud owner of Tutsmake.com. My passion lies in crafting informative tutorials and offering valuable tips to assist fellow developers on their coding journey. Within my content, I cover a spectrum of technologies, including PHP, Python, JavaScript, jQuery, Laravel, Livewire, CodeIgniter, Node.js, Express.js, Vue.js, Angular.js, React.js, MySQL, MongoDB, REST APIs, Windows, XAMPP, Linux, Ubuntu, Amazon AWS, Composer, SEO, WordPress, SSL, and Bootstrap. Whether you're starting out or looking for advanced examples, I provide step-by-step guides and practical demonstrations to make your learning experience seamless. Let's explore the diverse realms of coding together.

Leave a Reply

Your email address will not be published. Required fields are marked *