Skip to main content

Posts

Showing posts with the label C Program to Calculate Compound Interest

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 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 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 'n' to 1 (for Loop)

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