Float points and Doubles:
As we know integers are variables that contains whole numbers. They can not store numbers that contain point or decimal like 0.1 , 5.8 , 5.0089 or 10.776012, These numbers are stored in floats or doublesHow to Create Float Double Variable:
To create and float simple type float before the name of variable.
For example:
float num_1 ;
To create and Double simple type Double before the name of variable.
For example.
To create and Double simple type Double before the name of variable.
For example.
Double num_2 ;
How to assign a value to Float Double Variable:
To assign a value to a float variable you need to type the name of float of double then " = " equal sign and then type the value in numbers and remember to place semi column " ; " at the end.
For example.
For example.
num_1 = 10.23;
num_2=1.02356;
num_2=1.02356;
How to out put a value from Float or Double Variable:
To out put a value from a double or float variable you simple need to write the following code
Console.WriteLine( num_1 );
Console.WriteLine( num_2 );
Console.WriteLine( num_2 );
How to use the value stored in an Float or Double Variable:
If you want to use the value of float or double take the following example.
float num_3 = num_1 - num_2 ;
Console.WriteLine( num_3 );
No comments:
Post a Comment