Skip to main content

Posts

Showing posts with the label Print Even Numbers from 1 to 20- while Loop

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 Even Numbers from 1 to 20- while Loop

In this easy coded program, you will learn how to print even 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 Even Numbers from 1 to 20 /*Even Numbers from 1 to 20- while Loop*/ #include<stdio.h> void main () {     int i =2 ;     while (i <=20 )     {                 printf( "%d \t " , i);                 i +=2 ;     } }   Output 2 4 6 8 10 12 14 16 18 20 --------------------------------------------------------------...