CIS-60 Home http://www.c-jump.com/CIS60/CIS60syllabus.htm

C++ Fundamental Types and Declarations


  1. "Something in memory"
  2. Introduction
  3. Introduction, declared variables
  4. Every name has a type
  5. Type determines operations
  6. C++ Fundamental Types
  7. Boolean Type
  8. Boolean to integer conversion
  9. Character Data Type
  10. Character Set
  11. Character Literals
  12. Character Type Example
  13. Integer Types
  14. Integer Literals
  15. Floating-Point Numbers
  16. sizeof operator
  17. C++ variables
  18. Declaration Initializers
  19. Variable Names
  20. Variable Name Examples
  21. Scope of Variables
  22. Declaration Is a Statement

1. "Something in memory"



2. Introduction



3. Introduction, declared variables



4. Every name has a type



5. Type determines operations



6. C++ Fundamental Types



7. Boolean Type



8. Boolean to integer conversion



9. Character Data Type



10. Character Set



11. Character Literals



12. Character Type Example



13. Integer Types



14. Integer Literals

  • Integer literals are numeric constants, or numerals, in our programs.

  • There are 3 literal notations in C++,

    • decimal: 2

    • octal: 02

    • hexadecimal: 0x2

  • See also: Hexadecimal Notation

  •  

    
    #include <iostream> 
    void main() 
    { 
        int x = 15;   // decimal-15
        int y = 015;  // octal-15 (decimal 13)
        int z = 0x15; // hexadecimal-15 (decimal 21)
    } 
    
    

15. Floating-Point Numbers



16. sizeof operator



17. C++ variables



18. Declaration Initializers



19. Variable Names



20. Variable Name Examples



21. Scope of Variables


  •  

  • Global variable example:

    
    int count; // global variable
    void main() 
    { 
        count = count + 1; 
    } 
    
    
  •  

  • Local variable example:

    
    void main() 
    {
        int count = 0; // local variable
        count = count + 1; 
    } 
    
    

22. Declaration Is a Statement

  • thread of control and initializers

  • avoid uninitialized variables

  • avoid global variables

  • 
    void main() 
    {
        int count = 0;
        count = count + 1; 
    }