May 23, 2023
program to use floating arithmetic operator c language
#include<stdio.h>
int main()
{
float a=12.4,b=3.8,s;
s=a+b;
printf("sum=%.2f\n",s);
s=a-b;
printf("difference=%.2f\n",s);
s=a*b;
printf("product=%.2f\n",s);
s=a/b;
printf("a/b=%.2f\n",s);
return 0;
}
output
sum=16.20
difference=8.60
product=47.12
a/b=3.26
Steps Description
- Declare float three variable
a
,b
ands
- Initialize in float variable
a=12.4
b=3.8
- Assign
S
variable with sum of variablea
andb
printf
inbuild function displayS
variable with decimal placeholder %d- Assign
S
variable with difference of variablea
andb
printf
inbuild function displayS
variable with decimal placeholder %d- Assign
S
variable with product of variablea
andb
printf
inbuild function displayS
variable with decimal placeholder %d- Assign
S
variable with a/b of variablea
andb
printf
inbuild function displayS
variable with decimal placeholder %d
by : Ajaj Khan
Quick Summary:
floating arithmetic operator in c language