Basic HTML Version

|  | Table of Contents |  | View Full Version

Page 86 - 2625 PortGPt V2.1
P. 86

    Coding           uiz   01
                                                                                                           Subject Enrichment

                          State whether the following statements are true (T) or false (F).

                          a.  Part of the code in which the variable can be used is scope.

                          b.  Variable name must begin with a special character.

                      DATA TYPES
                      Variables contain the values on which the operations are performed. Every variable needs
                      to be assigned to a specific data type to make it accessible for the computer.

                      Data type  identifies  the type  of  data which  the  declared  variable can  hold.  It  helps  the
                      computer to understand what operations need to be performed on the declared variables.

                      The common data types are:

                          Data Type                       Description                   Declaration         Example

                       Integer (int)           It represents whole numbers  int x=4;                    5, 10, 988
                                                (zero, positive, negative value, not
                                                the decimal value)/integer value).
                                               Assigning non-integer value to
                                                integer type variable returns error.
                                               Integer type variable holds only a
                                                single value.

                       Floating Point          It  represents  real numbers  with  float x= 5.1;        4.65, 8.05, 10.1
                       Numbers (float)          decimal values or fractions.            double x=
                                               Another  type  of  floating-point  9.99*8.888
                                                number  is  'double'  data  type,  to
                                                store even bigger values.

                       Character (char)        It holds a single letter. (e.g., a.b.c.) char x='y';     90  (in  ASCII,  90
                                               The syntax of declaring a character                      is a upper case
                                                type variable is specific to the                        'Z')
                                                programing language.
                                               It is the smallest data type by size.
                                               Assigning a non-character type
                                                value to a character type variable
                                                returns error.

                      84    Premium Edition-VI

| 81 82 83 84 85 86 87 88 89 90 91 |