About Me

My photo
Raipur, Chhattisgarh, India
Hi , I am Amit Thakur. I have worked as a QA Engineer for two years and as a Java Developer for one year in NIHILENT TECHNOLOGIES PVT. LTD., Pune.Currently I am working as DEAN (Research & Development) in Bhilai Institute of Technology, Raipur.

Tuesday, September 3, 2013

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 = %fn", a ,b, a + b);
printf("%f - %f = %fn", a ,b, a - b);
printf("%f * %f = %fn", a ,b, a * b);
printf("%f / %f = %fn", 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 = %fn", a ,b, a % b);

}
Output :
Compile Error : Illegal Use of Floating Point

No comments: