In this tutorial you will learn about the C Program to Add Subtract Multiply Divide and its application with practical example.
C Program to Add Subtract Multiply Divide
In this tutorial, we will learn to create a C program that will Add, Subtract, Multiply & Divide using C programming.
Prerequisites
Before starting with this tutorial we assume that you are best aware of the following C programming topics:
- Operators in C Programming.
- Basic Input and Output function in C Programming.
- Basic C programming.
- Arithmetic operations in C Programming.
Program to Add Subtract Multiply Divide
In c programming, it is possible to take numerical input from the user and Add, Subtract, Multiply & Divide with the help of a very small amount of code. The C language has many types of header libraries which has supported function in them with the help of these files the programming is easy.
With the help of this program, we can Add Subtract Multiply Divide.
Here,
We will first take the input
The second will make a series and add the numbers.
Algorithm:-
1 2 3 4 5 6 7 8 9 10 11 |
1. Declaring the variables for the program. 2. Taking the input numbers from the user. 3. Passing those numbers to the arithmetic operations. 4. Add,substract,multiply,divide the numbers. 5. Printing the result number. 6. End Program. |
Program to Add Subtract Multiply Divide:-
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 |
#include <stdio.h> #include <stdlib.h> int main() { //declaring the variables for the program. int no1,no2; //taking the input numbers from the user printf("Enter the first number: "); scanf("%d",&no1); printf("Enter the second number: "); scanf("%d",&no2); //Printing the output addition for the numbers printf("\nAddition of %d + %d",no1,no2); printf(" = %d",(no1+no2 )); //Printing the output substraction for the numbers printf("\nSubstraction of %d - %d",no1,no2); printf(" = %d",(no1-no2)); //Printing the output multipliccation for the numbers printf("\nMultiplication of %d X %d",no1,no2); printf(" = %d",(no1*no2 )); //Printing the output division for the numbers printf("\nDivision of %d / %d",no1,no2); printf(" = %d",(no1/no2 )); return 0; } |
Output:-
In the above program, we have first initialized the required variable.
- no1 = it will hold the integer value.
- no2 = it will hold the integer value.
Input number from the user.
Program Logic Code and print the output.