Another Data Type
In the preceding program, a variable of type
int
was used. However, an
int
variable can
hold only whole numbers. It cannot be used when a fractional component is required. For
example, an
int
variable can hold the value 18, but not the value 18.3. Fortunately,
int
is
only one of several data types defined by C#. To allow numbers with fractional components,
C# defines two floating-point types:
float
and
double
, which represent single- and double-
precision values, respectively. Of the two,
double
is the most commonly used.
To declare a variable of type
double
, use a statement similar to that shown here:
double result;
Here,
result
is the name of the variable, which is of type
Do'stlaringiz bilan baham: |