C Program to demonstrates binary expressions using floating-point arithmetic

January 15, 2025 No Comments » Hits : 121





Program : C Program to demonstrates binary expressions using floating-point arithmetic

#include<stdio.h>
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);
}

Output :

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

#include<stdio.h>
main()
{
float a = 14.0;
float b = 5.0;
printf("%f %% %f = %f\n", a ,b, a % b);
}

Output :

Compile Error : Illegal Use of Floating Point

Incoming search terms: