The Basic Data Types

  1. Basic data types
    1. char - character 8 bit ASCII characters
    2. wchar_t - wide character for languages with large number of characters
    3. int - integer no fractional component
    4. float - floating point has fractional component
    5. double - double floating point about 10 x larger than float
    6. bool - Boolean true or false
    7. void - valueless when a value isn't returned

  2. Declaration of variables
    1. type variable_list;
    2. where declared
      1. local variables - inside functions
        1. created when the function is called
        2. destroyed when the function is exited
      2. formal parameters - in the definition of function parameters
        1. arguments of a function
        2. like a local variable
      3. global variables - outside of all functions
        1. declare them outside all functions - at the top of the program

    3. Type Modifiers
      1. signed applied to integers (redundant) and characters
      2. unsigned applied to integers and characters
      3. long applied to double
      4. short applied to integers

    4. Constants
      1. Fixed values that cannot be altered by the program
      2. Types
        1. character constants are between single quotes ` `
        2. wide character - precede the character with L
        3. integers - numbers without fractional component
        4. floating-point - decimal point or scientific notation
        5. type can be specified
        6. hexadecimal - 0x
        7. octal - begins with 0
        8. strings - an array of characters - double quotes " "
      3. Blackslash character constants
        1. \b - backspace
        2. \f - form feed
        3. \n - newline
        4. \r - carriage return
        5. \t - horizontal tab
        6. \" - double quotes
        7. \' - single quote
        8. \\ - backslash
        9. \v - vertical tab
        10. \a - alert
        11. \? - ?
        12. \N - octal constant
        13. \xN - hexadecimal constant

    5. Variable Initialization
      1. type variable_name = constant;
      2. global variables initialized only at the start of a program
      3. local variables initialized each time the function is entered unknown value until an assignment is made unless specified

    6. Operators - a symbol that tells the compiler to perform specific mathematical or logical manipulations
      1. arithmetic operators -
        1. standard + - * /
        2. modulus % - remainder of an integer division
          1. can't be used with float or double
        3. increment and decrement
          1. increment ++ adds one
          2. decrement -- subtracts one
      2. relational - > ,>=,<,<+,==,!=
        1. outcome is a bool
      3. logical
        1. AND - &&
        2. OR - ||
        3. NOT - !
      4. precedence of operators

    7. Expressions
      1. when different types are used in expressions, they are converted to the same type
        1. convert up to lartest operand
      2. casts - force an expression to be a specific type (type) expression
      3. spacing and parentheses are use for clarification

        Back to the Main Menu