Skip to main content

Posts

Showing posts with the label Division of Two Numbers using Two Variables

C Program to Print Numbers from b to a using while Loop

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

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 Calculate Simple Interest

In this easy coded program, you will learn how to calculate simple interest by taking input of principle amount, number of years and rate of interest from 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 /*Simple Interest*/ #include<stdio.h> void main () {         float p, n, r, si;         printf( "Enter Principle Amount, No. of Years, Rate of Interest= " );         scanf( "%f %f %f" , & p, & n, & r);         si = (p * n * r) /100 ;         printf(...

C Program to Find Sum of All Numbers till 'n'

In this easy coded program, you will learn how to find sum of all the numbers till 'n', where n is up to where you want the sum to be calculated. --------------------------------------------------------------------------- Program to Find Sum of Numbers Till 'n' /*Sum of All Numbers till n*/ #include<stdio.h> void main () {     int i, n, sum =0 ;     printf( "Enter Number: " );     scanf( "%d" , & n);     for (i =1 ; i <= n; i ++ )     {         sum = sum + i;     }     printf( "The sum of all the numbers till %d is %d." , n, sum); } Output   Enter Number : 20 The sum of all the numbers till 20 is 210. ----------------------------------------------------------------...