answersLogoWhite

0


Best Answer

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).

User Avatar

Wiki User

10y ago
This answer is:
User Avatar
More answers
User Avatar

Wiki User

7y ago

In C++ we use the float, double and long double data types to represent real numbers with various degrees of precision. The type double provides at least as much precision as a float while a long double provides at least as much precision as a double. On most implementations, a double has twice the precision of a float, however the actual precision is implementation defined.

This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a floating point variable in c?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

Is 10e10 can be used in c?

Yes, as a floating point constant.


What are the types of data type?

Character or small integerShort IntegerIntegerLong integerBooleanFloating point numbersDouble precision floating point numberLong double precision floating point numberWide characterTo get a better idea on C++ data types, see related links below.


How do you Write a value returning function using c programming that receives two floating point numbers and returns true if the first formal parameter is greater than the second.?

bool isBigger (float a, float b) { return a > b;}


What is a pointer variable in C?

Pointer variables point to data variables. They are mostly used to point to dynamically allocated data variables, but can actually point to anything (e.g. statically allocated variables, array elements, anywhere inside a variable, program machine code, I/O device descriptors, nonexistent memory). Misuse of pointer variables, either unintentionally or intentionally, is a major cause of nearly impossible to debug software problems in programs written in C (and C++).


What is this percentd in C programming what does input and output mean How do I make the solution include decimal?

The %d designation is a printf format specification that says to interpret the next argument as a signed integer and display the results in base 10 decimal. Input and output is the processing of input data and output data by your program. Usually, input is the stdin file, which is processed by scanf, and output is the stdout file, which is processed by printf. To include a decimal point in the output, you need to use a floating point variable and a floating point specification, such as %f.

Related questions

How do you save a radian value in c plus plus?

You can write it into a file as a floating-point value.


What is 10.1455785 in c language?

A floating point constant value.


Is 10e10 can be used in c?

Yes, as a floating point constant.


How would you write 12 of the variable c?

12c


What is the possible reason if the turbo C compiler displays an error like this Illegal use of floating point?

Floating-point library not linked in.


C program to receive floating point and convert it into binary?

scanf


What is the c code for printing binary value of floating point values?

16


What is IEEE standard in c plus plus?

The format of floating-point numbers. On some platforms.


Floating point number in c-language?

any real number e.g, 15.5 1456.223 4568.12


How do you write a c program to perform addition on two floating point values and display the result?

void print_sum (float a, float b) { printf ("The sum of %d and %d is %d\n", a, b, a+b); }


What are the types of data type?

Character or small integerShort IntegerIntegerLong integerBooleanFloating point numbersDouble precision floating point numberLong double precision floating point numberWide characterTo get a better idea on C++ data types, see related links below.


What is the meaning of fabs in quadratic equation in c program?

In the C Programming Language, the fabs function returns the absolute value of a floating-point number