Computer Concept & Programming In C - Unit II - 5

Q.5 What do you understand by the double data type? How is it differ from the float data type?
Ans. The Double Data Type: -
In the C language, a floating point number can also be represented by another data type called the double data type. In other words you can specify a variable by the double key word and assign the variable a floating-point number.
The difference between a double data type and float data type is that the dooble normally uses twice as many bits as the float. Therefore a double floating point number is of at least 10 digits of precision, although the ANSI standard does not specify it for the double data type.
Using Scientific Notation: -
The C language uses scientific notation to help, write lengthy floating numbers.
In scientific notation a number can be represented by the combination of mantissa and the exponent. The format of the notation is that mantissa is followed by the exponent which is prefixed by e or E. here are two examples:
[mantissa] e [exponent].
and
[mantissa] E [Exponent].
For instance, 5000 can be represented by 5e3 in the scientific notation. Likewise, -300 can be represented by –3e2 and 0.0025 by 2.5e-3.
Correspondingly the format specifier, %e or %E, is used to format a floating point number in scientific notation.
The usage of %e or %E in the printf( ) notation is the same as %f.

Q.6 What are fundamental data types and their modifiers?
Related Questions -
Q. Explain the various data types in C giving suitable examples of each.                                               (AKTU. 2009-10, 10 - 11)
Q. List any two data type qualifiers and two data type modifiers.
                                                     (AKTU. 2012 - 13)
Ans. Basic Data Types: -
The memory locations, which store data values, are called variables. The variables are identified by names (identifiers) and are classified in various types. The variable types (or data types) must be declared at the beginning of the program.


Data type modifiers: -
The basic data types may be modified by adding several special keywords called data type modifiers to produce new features or new types. The modifiers are:
(i) Signed (ii) Unsigned (iii) Long (iv) Short.
Except with void types, the modifiers can be used with all basic data types according to the combinations.

Note that if you do not specify the basic type it is by default int. for example, short is the same as short int. Also the signed modifier is the default, which means that type signed int is the same as int.
This way some types in the table are just duplicate of others.
As you see in the table, using the unsigned modifiers means doubling the maximum range of the stored number.
The unsigned data types, however, hold positive numbers only (including zero). In other words, it is a trade off between using negative numbers and doubling the storage range.