Data types A data type is a classification that dictates what a variable or object can hold
3 Basic Major Data Types Numerical Alphabetic Logical
Numerical Two broad categories Integer numbers Whole number 3 types : int , short and long) Floating point numbers 2 types: float and double Can be represented by Decimal: 3.1478 Scientific notation: 2.75e3 same as 2.75 x 10 3
Alphabetic Data Type Character Data type Store a single character Represented in single quote: ‘x’ , ‘A’ Strings Data type Store 2 more characters : “Melissa” or “apple” Keyword is string
Logical Data Supports two vaues : true or false Keyword: bool
C++ Primitive Data Types Primitive types integral floating char short int long bool float double long double unsigned
What is an Identifier? An identifier is the name to denote labels, types, variables, constants or functions, in a C++ program. C++ is a case-sensitive language. Age is not age Identifiers should be descriptive Using meaningful identifiers is a good programming practice
Rules in Naming Identifier You can use upper and lowercase letters, digits from 0 to 9, and underscore(_). The first character must be letter or underscore ( _ ). Don’t contains any blank,<,>,&,!,%,^,*,…etc. C++ is case sensitive –uppercase and lowercase letters are different, so a1 and A1 are different identifier. Not a keyword( int , float, double char, void, return main) Don’t give the same name to two different variables .
The C++ Key Words
Variable Location on computer’s memory to store data then use and change its value in a program