Skip to main content

Posts

Showing posts with the label Print Numbers from 'n' to 1 (while Loop)

C Program to Print Odd Numbers from 1 to 20- while Loop

In this easy coded program, you will learn how to print odd numbers from 1 to 20 using while loop. You will not need to take any input from the user as we are defining the end point. --------------------------------------------------------------------------- Program to Print Odd Numbers from 1 to 20 /*Odd Numbers from 1 to 20- while Loop*/ #include<stdio.h> void main () {     int i =1 ;     while (i <=20 )         {             printf( "%d \t " , i);             i +=2 ;         } }   Output 1 3 5 7 9 11 13 15 17 19 ---------------------------------------------------------...

C Program to Print Numbers from 'n' to 1 (while Loop)

In this easy coded program, you will learn how to print numbers from 'n' to 1 using while loop, where 'n' is taken from the user. You will have to take input of the first number that the user wants to print and simply write the code for its execution. --------------------------------------------------------------------------- Program to Print Numbers from 'n' to 1 (while Loop) /*Print Numbers from n to 1- while loop*/ #include<stdio.h> void main () {     int num;     printf( "Enter Number: " );     scanf( "%d" , & num);     while (num >=1 )     {         printf( "%d \t " ,num -- );     } }   Enter Number : 7 7 6 5 4 ...