Saturday, August 12, 2017

C Programming; Lesson 3: Numbers and Characters

Numbers:

In the C language there are essentially two types of numbers:
                                          integers
                                          real numbers (floating-point numbers)

             type                                         bytes                    range value                                                                   char                                            1                       -128 to 127                                                                      int                                              2                     -32768 to 32767                                                            short int                                         2                     -32768 to 32757                                                             long int                                         4                  -2147483648 to 2147483647                                             float                                            4               -3.4 * 10^38 to -3.4 * 10^38 and                                                                                                                3.4 * 10^-38 to 3.4 * 10^38                                                 double                                           8              -1.7 * 10^308 to -1.7 * 10^-308 and                                                                                                          1.7 * 10^-308 to 1.7 * 10^308                                          long double                                    10              -1.1 * 10^4932 to -3.4 * 10^-4932 and                                                                                                       3.4 * 10^-4932 to 1.1 * 10^-4932
If the type of variable is defined with the additional word unsigned then the range is moved to the positive area.

Characters:

char- serves to save the ASCII values of a single character.
To save a character we use: char a = 'b';

1 comment: