What is the usage of real constants in the C language?

In the C language, real constants refer to floating point constants, which are numbers that contain decimal points. Real constants can be used for mathematical operations and assignment operations. Here are some examples of real constant usage:

  1. Mathematical operations:
  2. Addition: float sum equals 3.14 plus 2.718.
  3. Subtraction: double difference = 10.5 minus 3.2;
  4. Multiplication: calculate the product by multiplying 2.5 and 4.8.
  5. Division: calculate the double quotient by dividing 7.0 by 2.0.
  6. Assignment operation:
  7. The radius is equal to 5.0.
  8. Assign the value of 3.14159 to the variable pi.
  9. Function parameters:
  10. Print the floating point number.
  11. Output the floating-point number 3.14.

It is important to note that in C language, real constants are double by default. If you want to represent a float type constant, you need to add a “f” or “F” suffix after the number, for example: float num = 3.14f;

bannerAds