Write a program to perform arithmetic operations in c programming language.
The program will take two integers as the input from the user. And then we will perform the addition, subtraction, multiplication, division, and modulus of the two integers.
Example: Arithmetic Operations:
Input:
1
Enter two integers:2010
Output:
1
2
3
4
5
Addition of20and10is:30
Subtraction of20and10is:10
Product of20and10is:200
Division of20and10is:2
Modulus of20and10is:0
Program : Arithmetic Operations in C:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
#include<stdio.h>
intmain(void)
{
inta,b;
// Take input from the user.
printf("Enter two integers : ");
scanf("%d%d",&a,&b);
// Perform all arithmetic operations.
printf("Addition of %d and %d is : %d\n",a,b,a+b);
printf("Subtraction of %d and %d is : %d\n",a,b,a-b);
printf("Product of %d and %d is : %d\n",a,b,a*b);
printf("Division of %d and %d is : %d\n",a,b,a/b);
printf("Modulus of %d and %d is : %d\n",a,b,a%b);
return0;
}
Above program will take two integers from user and then uses the in-built addition operator ( ‘+’ ) to perform the sum of two integer.
Similarly we use subtraction operator ( ‘-‘ ), Multiplication operator ( ‘*’ ), Division Operator ( ‘/’ ) and Modulus Operators ( ‘%’ ) to perform remaining arithmetic operations.
We have discussed more about the arithmetic operators in the following article. Please go through it for more info
[…] The goal of the program is to familiarize ourselves with the functions. As we have written the arithmetic operations programs earlier without using […]
4 Responses
[…] Arithmetic Operations in C programming – SillyCodes […]
[…] C Program to perform all Arithmetic Operations […]
[…] C Program to perform all Arithmetic Operations […]
[…] The goal of the program is to familiarize ourselves with the functions. As we have written the arithmetic operations programs earlier without using […]