Page 100 - Computer Genius Class 06
P. 100

The common data types are:


                    Data Type                        Used for                         Declaration        Example

                   Integer          It represents whole numbers (zero, positive,     int a=2;         7, 12, 999
                   (int)           negative value, not the decimal value)/integer
                                   value.
                                    Assigning non-integer values to integer
                                   variable returns an error.

                                   Variable holds only a single value.

                   Floating         It represents a real number with decimal         Float a=5.1;     3.15, 9.06,
                   point           values or fraction.                               Double           00.13
                     oat             nother type o   oating point num er is          a=9.99*8.888
                                   "double" data type, to store even bigger values.

                   Character       It” holds a single letter (e.g. a, b, c).         Char a=’z’;      97 (in ASCII,
                   (char)           The syntax of declaring a character variable                      97 is a lower

                                   is specific to the programing language.                            case 'a')
                                   It is the smallest data type by size.
                                    Assigning a non-character type value to
                                   character type  variable returns error.


                   String (str)     It represents alphanumeric characters and        String           hello world,
                                   stores sequence of characters.                    a=“Hello”        Alice, Bob123
                                    It is used for the combination of any
                                   character which appears on the keyboard
                                   (letters, numbers, symbols).
                                    In python string variables can be declared
                                   either by single quotes or double quotes or
                                   triple quotes.

                   Boolean         It represents logical values.                     Bool b=false;    TRUE, FALSE
                   (bool)           It stores values in Boolean type only i.e. “true
                                   (1)” or “false (0)”.
                                   It is a subtype of integer data type.







                           Google was founded by Larry Page and Sergey Brin when they
                           were Ph.D. students at Stanford University in California.






                       98    Computer Genius-VI
   95   96   97   98   99   100   101   102   103   104   105