C Program to Print First N Natural Numbers in Reverse

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.

C Program to Print First N Natural Numbers in Reverse

  • 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

AuthorAdmin

My name is Devendra Dode. I am a full-stack developer, entrepreneur, and owner of Tutsmake.com. I like writing tutorials and tips that can help other developers. I share tutorials of 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 from a starting stage. As well as demo example.

Leave a Reply

Your email address will not be published.