Skip to main content

Posts

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

C Program to Print Even Numbers from 1 to n using for Loop

In this easy coded program, you will learn how to print even numbers from 1 to 'n' using for loop. Here, 'n' is the number up to which the user wants the even numbers to be printed. --------------------------------------------------------------------------- Program to Print Even Numbers from 1 to n using for Loop /*Even Numbers from 1 to n- for Loop*/ #include<stdio.h> void main () {     int i, num;     printf( "Enter Number: " );     scanf( "%d" , & num);     for (i =2 ; i <= num; i +=2 )         printf( "%d \t " , i); }   Output Enter Number : 8 2 4 6 8 --------------------------------------------------------------------------- Hope you found this ' C Program to Print Even Numbers from 1 to n using for...

C Program to Print Odd Numbers from 1 to n using for Loop

In this easy coded program, you will learn how to print odd numbers from 1 to 'n' using for loop. Here, 'n' is the number up to which the user wants the odd numbers to be printed. --------------------------------------------------------------------------- Program to Print Odd Numbers from 1 to n using for Loop /*Odd Numbers from 1 to n- for Loop*/ #include<stdio.h> void main () {     int i, num;     printf( "Enter Number: " );     scanf( "%d" , & num);     for (i =1 ; i <= num; i +=2 )         printf( "%d \t " , i); }   Output Enter Number : 8 1 3 5 7 --------------------------------------------------------------------------- Hope you found this ' C Program to P...

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 Odd Numbers from 1 to 'n'- while Loop

In this easy coded program, you will learn how to print odd numbers from 1 to 'n' using while loop. Here, 'n',i.e. the end point will be given by the user and hence we will need to take input of the same. --------------------------------------------------------------------------- Program to Print Odd Numbers from 1 to 'n' /*Odd Numbers from 1 to n- while Loop*/ #include<stdio.h> void main () {     int i =1 , num;     printf( "Enter Number: " );     scanf( "%d" , & num);     while (i <= num)     {         printf( "%d \t " , i);         i +=2 ;     } }   Output Enter Number : 18 1 3 5 ...

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

In this easy coded program, you will learn how to print numbers from 1 up to the end decided by the user using while 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' (while Loop) /*Print Numbers from 1 to n- while loop*/ #include<stdio.h> void main () {     int i, num;     i =1 ;     printf( "Enter Number: " );     scanf( "%d" , & num);     while (i <= num)     {         printf( "%d \t " ,i ++ );     } } Output Enter Number : 7 1 2 3 4 5 6 7 ------...