C Program to Print First N Natural Numbers in Reverse

In this tutorial, i am going to show you how to print first n (10, 100, 1000 .. N) natural numbers in reverse in the c program using for loop, while loop and do-while loop.

Algorithm and Program to Print First N Natural Numbers in Reverse 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

Follow the below given 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 result 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 result 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 result 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 

More C Programming Tutorials

Be First to Comment

Leave a Reply

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