In C, a double data type is used to increase the accuracy of the real number wherever a float is not sufficient.A double data type occupies 8 bytes (64 bits) of memory to store real numbers, which have atleast one digit after the decimal point.A double data type can hold any value between 1.7E-308 to 1.7E+308.double data type values have a precision of 14 digits i.e., they can have 14 digits after the decimal point.Consider the following example using a double data type.#include <stdio.h>void main() { double num1 = 26.7368; double num2 = 1.42924; double total; total = num1 + num2; printf("Total of the given two numbers = %f\n", total);}Here, 8 bytes of memory is allocated to each variable num1, num2 and they are initialized with real number constants 26.7368 and 1.42924 respectively.Click on Live Demo to know about double data type in C.To further extend the precision of a double data type, the user can use long double data type. The long double type is guaranteed to have more bits than a double, while the exact number may vary from one hardware platform to another.A long double data type allocates 10 bytes(80 bits) of memory to store the given values.A long double data type can hold any value between 3.4E-4932 to 1.1E+4932.Select all the correct statements from the given statements.A double data type occupies 8 bytes of memory.A double data type can have up to 10 decimal places for the fractional part.A long double data type allocates 16 bytes of memory to the variables.A double data type uses 1 bit for sign, 10 bits for exponent value and 53 bits for mantissa part.
Question
In C, a double data type is used to increase the accuracy of the real number wherever a float is not sufficient.A double data type occupies 8 bytes (64 bits) of memory to store real numbers, which have atleast one digit after the decimal point.A double data type can hold any value between 1.7E-308 to 1.7E+308.double data type values have a precision of 14 digits i.e., they can have 14 digits after the decimal point.Consider the following example using a double data type.#include <stdio.h>void main() { double num1 = 26.7368; double num2 = 1.42924; double total; total = num1 + num2; printf("Total of the given two numbers = %f\n", total);}Here, 8 bytes of memory is allocated to each variable num1, num2 and they are initialized with real number constants 26.7368 and 1.42924 respectively.Click on Live Demo to know about double data type in C.To further extend the precision of a double data type, the user can use long double data type. The long double type is guaranteed to have more bits than a double, while the exact number may vary from one hardware platform to another.A long double data type allocates 10 bytes(80 bits) of memory to store the given values.A long double data type can hold any value between 3.4E-4932 to 1.1E+4932.Select all the correct statements from the given statements.A double data type occupies 8 bytes of memory.A double data type can have up to 10 decimal places for the fractional part.A long double data type allocates 16 bytes of memory to the variables.A double data type uses 1 bit for sign, 10 bits for exponent value and 53 bits for mantissa part.
Solution
The correct statements from the given ones are:
- A double data type occupies 8 bytes of memory.
- A double data type uses 1 bit for sign, 10 bits for exponent value and 53 bits for mantissa part.
The incorrect statements are:
- A double data type can have up to 10 decimal places for the fractional part. This is incorrect because a double data type can have up to 14 decimal places for the fractional part.
- A long double data type allocates 16 bytes of memory to the variables. This is incorrect because a long double data type typically allocates 10 bytes of memory to the variables, but the exact size can vary depending on the hardware and compiler used.
Similar Questions
Which data type is used for precise decimal calculations in C
What is the size of the float data type in C?
answerThe long data type in C is often used for:OptionsSmall integersSingle-precision floating-point valuesLarge integersDouble-precision floating-point values
Which of the following data types is not supported by C but is supported by C++?a.floatb.intc.doubled.bool
Which is the correct format specifier for double type value in C?
Upgrade your grade with Knowee
Get personalized homework help. Review tough concepts in more detail, or go deeper into your topic by exploring other relevant questions.