**Ex:**Write a C program to print addition, subtraction, multiplication, division of given two numbers. How to print addition, subtraction, multiplication, division of given two numbers. C program to print addition, subtraction, multiplication, division of given two numbers.

**Input from user:**

Enter value of a&b: 15 10

**Expected output:**

Addition is: 25

Subtraction is: 5

Multiplication is: 150

Division is: 1.0000

**Step by step logic of the given program:**

1. Accept input two numbers from user declare variable a & b.

2. Add two numbers and store it in some variable say sum, Subtraction of numbers store in variable sub, multiply two numbers store it in variable mult and last devide number and store it in float variable div.

3. Print

__sum__,__sub__,__mult__and__div__on the output screen.**Program:**

/***program to print addition, multiplication, subtraction and division***/

#include<stdio.h>

void main()

{

int a,b,sum,sub,mult;

float div;//variables declaration

//accept input from user

printf("Enter the value of a&b\n");

scanf("%d%d",&a,&b);

// logic to print addition, subtraction, multiplication and division

sum=a+b;

sub=a-b;

mult=a*b;

div=a/b;

// display addition

printf("Addition is %d\n",sum);

//display subtraction

printf("subtraction is %d\n",sub);

//display multiplication

printf("multiplication is %d\n",mult);

//display division

printf("division is %f",div);

}

## 0 comments:

## Post a Comment

If you have any doubts, please discuss here...