C Program To Input Two Values And Print Their Addition, Subtraction, Multiplication And Division.

Q5. Write a C program to input two values and print their addition, subtraction, multiplication and division.

Solution:

 

#include<stdio.h> //standard input/output header file

#include<conio.h> //for clrscr()

 

int main()

{

int a,b,c,d,e,f;

 

clrscr(); //to clear the screen

 

printf(“\n Enter first value: “);

scanf(“%d”,&a);

printf(“\n Enter second value: “);

scanf(“%d”,&b);

 

c=a+b;

d=a-b;

e=a*b;

f=a/b;

 

printf(“\n There sum is: %d”,c);

printf(“\n There subtraction is: %d”,d);

printf(“\n There multiplication is: %d”,e);

printf(“\n There division is: %d”,f);

 

getch(); //holds the screen until a key is pressed

return 0; //makes the main() finish

}

 

OUTPUT:

Enter first value: 8

Enter second value: 3

 

There sum is: 11

There subtraction is: 5

There multiplication is: 24

There division is: 2

Leave a Reply

Your email address will not be published. Required fields are marked *

%d bloggers like this: