C Program to Demonstrates binary expressions using floating-point arithmetic
Program : C Program to demonstrates binary expressions using floating-point arithmetic
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 | #include<stdio.h> int main() { /* Local Definitions */ float a = 14.0; float b = 5.0; /*Statements*/ printf("%f + %f = %f\n", a, b, a + b); printf("%f - %f = %f\n", a, b, a - b); printf("%f * %f = %f\n", a, b, a * b); printf("%f / %f = %f\n", a, b, a / b); return (0); } |
Output :
1 2 3 4 | 14.000000 + 5.000000 = 19.000000 14.000000 - 5.000000 = 9.000000 14.000000 * 5.000000 = 70.000000 14.000000 / 5.000000 = 2.800000 |
Floating Pointer Can perform following Operations :
- Addition
- Subtraction
- Division
- Multiplication
Note : Floating Point Data Type Can’t Perform Modulus Operation
1 2 3 4 5 6 7 8 | #include<stdio.h> main() { float a = 14.0; float b = 5.0; printf("%f %% %f = %fn", a, b, a % b); } |
Output :
1 | Compile Error : Illegal Use of Floating Point |