-->

Facebook

Jasper Roberts - Blog

Thursday, September 18, 2014

Write a C Program that reads two nos. from key board and gives their addition, subtraction, multiplication, division and modulo.

#include<stdio.h>
#include<conio.h>

void main()
{
int value1, value2, addition, subtraction, multiply;
float divide,mod;

clrscr();

printf("\n Enter the value1: ");
scanf("%d",&value1);

printf("\n Enter the value2: ");
scanf("%d",&value2);

addition = value1 + value2;
subtraction = value1 - value2;
multiply = value1 * value2;
divide = value1 / (float)value2;
mod = value1 % value2;

printf("\n Addition       = %d + %d = %d",value1,value2,addition);
printf("\n Subtraction    = %d - %d = %d",value1,value2,subtraction);
printf("\n Multiplication = %d * %d = %d",value1,value2,multiply);
printf("\n Division       = %d / %d = %.0f",value1,value2,divide);
printf("\n Modulo         = %d MOD %d = %.0f",value1,value2,mod);
 
    getch();
}

OUTPUT:

c program to add, sub, multi, div of two numbers
calculator.c


RELATED PROGRAMS

a. Writea program to print ―HELLO FRIENDS!!
c. Writea program to convert years intomonths and days. 
d. Write a prograto solve Quadratic Equation.





No comments:

Post a Comment