Skip to main content

Posts

Showing posts with the label Table of 'n'

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 Numbers from a to b using while Loop

In this easy coded program, you will learn how to print numbers from a to b using while loop, where the values of both will be taken from the user. --------------------------------------------------------------------------- Program to Print Numbers from a to b using while Loop /*Print Numbers from a to b- while Loop*/ #include<stdio.h> void main () {     int a, b;     printf( "Enter First Number: " );     scanf( "%d" , & a);     printf( " \n Enter Last Number: " );     scanf( "%d" , & b);     while (a <= b)     {         printf( "%d \t " , a);         ++ a;     }...

C Program to Print Even Numbers from 1 to 'n'- while Loop

In this easy coded program, you will learn how to print even 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 Even Numbers from 1 to 'n' /*Even Numbers from 1 to n- while Loop*/ #include<stdio.h> void main () {     int i =2 , num;     printf( "Enter Number: " );     scanf( "%d" , & num);     while (i <= num)     {                 printf( "%d \t " , i);                 i +=2 ;     } }   Outpu...

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