# Float and Double in C

## Float

Float is a datatype which is used to represent the floating point numbers. It is a 32-bit IEEE 754 single precision floating point number (1-bit for the sign, 8-bit for exponent, 23*-bit for the value. It has 6 decimal digits of precision.

Here is the syntax of float in C language,

float variable_name;

Here is an example of float in C language,

## Example

Live Demo

#include<stdio.h>
#include<string.h>
int main() {
float x = 10.327;
int y = 28;
printf("The float value : %f", x);
printf("The sum of float and int variable : %f", (x+y));
return 0;
}

## Output

The float value : 10.327000
The sum of float and int variable : 38.327000

## Double

Double is also a datatype which is used to represent the floating point numbers. It is a 64-bit IEEE 754 double precision floating point number for the value. It has 15 decimal digits of precision.

Here is the syntax of double in C language,

double variable_name;

Here is an example of double in C language,

## Example

Live Demo

#include<stdio.h>
#include<string.h>
int main() {
float x = 10.327;
double y = 4244.546;
int z = 28;
printf("The float value : %f", x);
printf("The double value : %f", y);
printf("The sum of float,
double and int variable : %f", (x+y+z));
return 0;
}

## Output

The float value : 10.327000
The double value : 4244.546000
The sum of float, double and int variable : 4282.873000

karthikeya Boyini

I love programming (: That's all I know

Updated on: 02-Sep-2023

49K+ Views

##### Kickstart Your Career

Get certified by completing the course

Advertisements