Program to print numbers from n to 1 using Do While loop.| Using C language| C Program series 15|
👨💻Program to print numbers from n to 1 using Do While loop.
Code:
//Program to print numbers from n to 1 using Do While loop.
#include<stdio.h>
main()
{
printf("Program to print numbers from n to 1 using Do While loop.\n\n");
int n;
printf("Enter the value of n:");
scanf("%d",&n);
do
{
printf("%d\n",n);
n--;
}while(n>0);
/*NOTE:
Here, we used 'Do while loop' so it first executes and then checks its condition.
So, this loop is executed at least once for any value of n, for example n=-67
*/
}
Output:
Comments
Post a Comment