Computer Science, asked by adarshtiwari48605, 1 month ago

c program print all natural numbers in reverse (from n to 1) using while loop​

Answers

Answered by anindyaadhikari13
5

Solution:

The given códe is written in C.

#include <stdio.h>

int main(){

   int n;

   printf("Enter n - ");

   scanf("%d",&n);

   while(n>0)

      printf("%d ",n--);

   return 0;

}

Logic:

  • Accept the value of n from the user.
  • Loop while n>0 -
  •   Display the value of n.
  •   Decrement the value of n.

See the attachment for output.

Attachments:
Similar questions