Next: Example 1:Convert the Gallons
Up: Language Elements
Previous: Language Elements
In C++, all variables must be declared before they are used. Also, the type of
values that a variable can hold must be specified. Here we list the types of
variables:
- 1.
- int This means that the variable may hold only integer values
(whole numbers). For most compilers this means the whole number values between
-32,768 and 32,767. In C++ to declare a variable to be type of integer, precede
its name with the keyword
.
- 2.
- float For
fractions one must use a floating point data type. One of these is called
. Data of this
type will typically be in the range 3.4E-38 to 3.4E+38. Operations on floating point numbers
preserve any functional part of the outcome and hence provide a more accurate conversion.
- 3.
- long Values in the range -2,147,483,648 through 2,147,483,647
- 4.
- double Values in the range 1.7E-308 through 1.7E308
- 5.
- char Normally used to store letters of the alphabet.
Yousef Haik
2/23/1998