How to use floating point arithmetic operators in C language
Floating Point Arithmetic Operators
On this page
Arithmetic Operators
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 and b
- Initialize in float variable a = 10.4, b = 5.8
- printf inbuild function to display sum of variable a > and b with decimal place holder %f
- prinf inbuild function to display difference of variable a and b with decimal place holder %f
- printf inbuild function to display product of variable a and b with decimal place holder %f
- printf inbuild function to display a/ba and b with decimal place holder%f