Program: 2
Write a C program to to perform basic functionality of calculator.
#include
#include
void main()
{
int a, b, add, sub, mul;
float div;
printf("Enter First Number: ");
scanf("%d",&a);
printf("Enter Second Number: ");
scanf("%d",&b);
add=a+b;
sub=a-b;
mul=a*b;
div=a/b;
printf("The addition of %d and %d is: %d\n", a, b, add);
printf("The subtraction of %d and %d is: %d\n", a, b, sub);
printf("The multiplication of %d and %d is: %d\n", a, b, mul);
printf("The division of %d and %d is: %f\n", a, b, div);
getch();
}
|
Output |
Enter First Number: 8 Enter Second Number: 4 The addition of 8 and 4 is: 12 The subtraction of 8 and 4 is: 4 The multiplication of 8 and 4 is: 32 The division of 8 and 4 is: 2.000000 |
Leave a Comment