C program to print addition, subtraction, multiplication and division of given two numbers

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 values 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 sumsubmult and div on the output screen.





  Program to print addition, subtraction, multiplication and division of given two numbers:


/***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);

}




Above program shows the following output:

program to print addition, subtraction, multiplication and division of given two numbers



Share your thoughts below in the comment section... :)

No comments:

Post a Comment

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