Skip to main content

Posts

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

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 ...

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

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