2-Write a C program to perform basic functionality of calculator

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
Lokesh Kumar: Being EASTER SCIENCE's founder, Lokesh Kumar wants to share his knowledge and ideas. His motive is "We assist you to choose the best", He believes in different thinking.
Related Post
Leave a Comment

This website uses cookies.