Skip to main content

Posts

Showing posts with the label Input & Output

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

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

C Program to Print Table of 'n'

In this easy coded program, you will learn how to print table of n. You will have to take input from the user for this program of any number of which the table needs to be calculated. --------------------------------------------------------------------------- Program to Print Table of 'n' /*Table of n*/ #include<stdio.h> void main () {     int num, i, a;     printf( "Enter Number: " );     scanf( "%d" , & num);     for (i =1 ; i <=10 ; i ++ )     {         a = num * i;         printf( " \n %d X %d = %d" , num, i, a);     } }   Output      Enter Number : 7 7 X 1 = 7 7 X 2 = 14 7 ...

C Program to Calculate Simple Interest Until User Says to Continue

In this easy coded program, you will learn how to calculate simple interest until the user says to continue by taking input of principle amount, number of years, rate of interest  and wish for continuation from the user. Try adding final calculated amount which will include the principle amount plus the calculated simple interest in this program for your self practice. --------------------------------------------------------------------------- Program to Calculate Simple Interest Until User Says to Continue /*Simple Interest Until User says to Continue- do while loop*/ #include<stdio.h> void main () {         float p, n, r, si;         char opt;         do     {         printf( "Enter Principle Amount, No. of Year...

C Program for Remainder of Two Numbers(3 Variables)

In this easy coded program, you will learn how the remainder of two numbers takes place using three variables. Actually, using less variables is preferred the most wherever possible. Rather, the same program can also be solved using two variables. --------------------------------------------------------------------------- Program for Remainder of Two Numbers /*Remainder of Two Numbers using Three Variables*/ #include<stdio.h> void main () {     int a, b, c;     printf( "Enter Two Numbers: " );     scanf( "%d %d" , & a, & b);     c = a % b;     printf( " \n The Remainder of %d and %d is %d." , a, b, c); } Output   Enter Two Numbers : 7 5 The Remainder of 7 and 5 is 2.  -------------------------------------------------------------...