
double Data Type in C: Usage and Examples
☰Fullscreen
Table of Content:
- double Variable Declaration and Variable Initialization:
- float Variable Declaration and Variable Initialization in two steps:
- double Variable Declaration and Variable Initialization in one line:
- Difference between float and double
- Related Assignment
- Stay Ahead of the Curve! Check out these trending topics and sharpen your skills.
Double data type is also same as float data type which allows up-to 10 digits after decimal. The range for double datatype is from 1E–37 to 1E+37.
double Variable Declaration and Variable Initialization:
Variable Declaration : To declare a variable , you must specify the data type & give the variable a unique name.
double area ;
Variable Initialization : To initialize a variable you must assign it a valid value.
area = 334343.14 ;
float Variable Declaration and Variable Initialization in two steps:
double area; area = 334343.14;
Program
// A Java program to demonstrate double data type class CharDemo { public static void main(String args[]) { double area; area = 323323.14; System.out.println(area); } }
Output
323323.14 Press any key to continue . . .
double Variable Declaration and Variable Initialization in one line:
double area= 334343.14 ;
Program
// A Java program to demonstrate double data type class CharDemo { public static void main(String args[]) { double area = 323323.14; System.out.println(area); } }
Output
323323.14 Press any key to continue . . .
Difference between float and double
The size of float (single precision float data type) is 4 bytes. And the size of double (double precision float data type) is 8 bytes. Floating point variables has a precision of 6 digits whereas the precision of double is 14 digits.
No Questions Data Available.
- Assignment 1: Write a program to illustrate the results of type conversion between float to int data type.
- Assignment 2: The packing department of a television vision set manufacturer has to prepare a requisition note listing the number of different boxes required for the different TV models that it has received from the production department. The list prepared has to be forwarded to the stores department so that the required boxes are issued to the packing department. The category and the number of boxes required for each type of TV model is given as follows: