How do you write a floating point variable in c?

1 answer

Answer

1089240

2026-05-07 20:00

+ Follow

You declare a floating point variable using the float or double keyWord for a single- or double-precision floating point variable, respectively:

float a;

double b;

You reference a floating-point variable just like any other scalar variable by using the variable's name in a compatible expression, e.g.

a += 2;

b /= a;

Floating point literals use a period for the decimal point, no "thousands separator," and use the letter 'e' to denote a power of ten, e.g.

a = 0.123;

b = 123e-3;

Both a and b now have the same value, 123 times 10 to the power of -3 (which equals 0.123).

ReportLike(0ShareFavorite

Copyright © 2026 eLLeNow.com All Rights Reserved.