May 25, 2023
program to use arithmetic operators in c language
#include<stdio.h>
int main()
{
int a=12,b=6,res;
res=a + b;
printf("sum : %d\n", res);
res=a-b;
printf("difference : %d\n", res);
res=a*b;
printf("product : %d\n", res);
res=a/b;
printf("quotient : %d\n", res);
res=a%b;
printf("remainder : %d\n", res);
return 0;
}
output
sum : 18
difference : 6
product : 72
quotient : 2
remainder : 0
Steps Description
- Declare integer three variable
a
,b
andres
- Initialize in integer variable
a=12
,b=6
- Assign
res
variable with sum of variablea
andb
printf
inbuild function displayres
variable with decimal placeholder %d- Assign
res
variable with difference of variablea
andb
printf
inbuild function displayres
variable with decimal placeholder %d- Assign
res
variable with product of variablea
andb
printf
inbuild function displayres
variable with decimal placeholder %d- Assign
res
variable with quotient of variablea
andb
printf
inbuild function displayres
variable with decimal placeholder %d- Assign
res
variable with remainder of variablea
andb
printf
inbuild function displayres
variable with decimal placeholder %d
by : Ajaj Khan
Quick Summary:
use arithmetic operators in c language