•Data type is a keyword used to identify type of data.
•It is used for storing the input of the program into the main memory (RAM) of the computer by allocating sufficient amount of memory space in the main memory of the computer. •In general every programming language is containing three categories of data types. They are 1. Fundamental or primitive data types 2. Derived data types 3. User defined data types Primitive data types These are the data types whose variable can hold maximum one value at a time, in C++ language it can be achieve by int, float, double, char. Derived data types 1. These data type are derived from fundamental data type. 2. Variables of derived data type allow us to store multiple values of same type in one variable but never allows to store multiple values of different types. User defined data types 1. User defined data types related variables allows us to store multiple values either of same type or different type or both. 2. This is a data type whose variable can hold more than one value of dissimilar type, in C++ language it is achieved by structure. Data type modifiers • The data type modifiers are listed here: 1. signed 2. unsigned 3. long 4. Short • The modifiers signed, unsigned, long, and short can be applied to integer base types. • In addition, signed and unsignedcan be applied to char, and long can be applied to double. Constants/Literal s • Constants refer to fixed values that the program may not alter and they are called literals. • Constants can be of any of the basic data types and can be divided into Integer Numerals, Floating-Point Numerals, Characters, Strings and Boolean Values. C++ allows several kinds of literal 1. Integer literals 2. Floating-point literals 3. Boolean literals 4. Character literals 5. String literals Integer Constants • An integer literal can be a decimal, octal, or hexadecimal constant. • A prefix specifies the base or radix: 0x or 0X for hexadecimal, 0 for octal, and nothing for decimal. • An integer literal can also have a suffix that is a combination of U and L, for unsigned and long, respectively. Floating-point Constants • A floating-point literal has an integer part, a decimal point, a fractional part, and an exponent part. Boolean Constants • There are two Boolean literals and they are part of standard C++ keywords: 1. A value of true representing true. 2. A value of false representing false. • You should not consider the value of true equal to 1 and value of false equal to 0. Character Constants • Character literals are enclosed in single quotes. String Constants • String literals are enclosed in double quotes. • A string contains characters that are similar to character literals: plain characters, escape sequences, and universal characters. The const Keyword Variable Declaration Rule in C++ • To Declare any variable in C++ you need to follow rules and regulation of C++ Language, which is given below; • Every variable name should start with alphabets or underscore (_). • No spaces are allowed in variable declaration. • Except underscore (_) no special symbol are allowed in the middle of the variable declaration. • Maximum length of variable is 8 characters depend on compiler and operation system. • Every variable name always should exist in the left hand side of assignment operator. •No keyword should access variable name. Syntax: Datatype variable_name; int a; Scope of Variable in C++ • In C++ language, a variable can be either of global or local scope. Global variable 1. Global variables are defined outside of all the functions, generally on top of the program. 2. The global variables will hold their value throughout the life-time of your program. Local variable 1. A local variable is declared within the body of a function or a block.