Page 70 - PortGPT_V2.1_C6_Flipbook
P. 70

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.





                  68    Premium Edition-VI
   65   66   67   68   69   70   71   72   73   74   75