June 12, 2023
Program to use floating point arithmetic operators in C language
#include <stdio.h>
int main()
{
float a = 12.4, b = 3.8;
printf("Sum=%.2f\n", a + b);
printf("Difference=%.2f\n", a - b);
printf("Proudct=%.2f\n", a * b);
printf("a/b=%.2f\n", a / b);
return 0;
}
Output
Sum=16.20
Difference=8.60
Proudct=47.12
a/b=3.26
Steps / Description
- Declare variable float
a
andb
- Initialize in float variable
a = 10.4
,b = 5.8
printf
inbuild function to display sum of variablea >
andb
with decimal place holder%f
prinf
inbuild function to display difference of variablea
andb
with decimal place holder%f
printf
inbuild function to display product of variablea
andb
with decimal place holder%f
printf
inbuild function to displaya/b
a andb
with decimal place holder%f
by : Nadeem Khan
Quick Summary:
Floating Point