You are on page 1of 25

Identifier The identifiers are the names used to represent variable ,constants, types functions in the program Types

of identifiers Standard identifiers User defined identifiers

Enge:Sajida Introduction to computing

Standard identifier A type of identifier that has the special meaning in the c++ cout and cin are example of standard identifiers User-defined Identifier The type of Identifier that is defined by the Programmer to access memory location known as user-defined Identifier.

Enge:Sajida Introduction to computing

The user-defined identifiers are used to store data and program results. Some examples of user-defined identifiers are, marks and age etc.

Enge:Sajida Introduction to computing

Keywords Keywords is a word in C++ language that has a predefined and purpose. The meaning and purpose of a keyword is defined by the developer of the language. It can not be changed or redefined by user. Keyword can be used for the same purpose for which it is defined. Keyword can be used for the same purpose for which it is defined.
Enge:Sajida Introduction to computing

Keywords are also known as reserved words. These are different types of keywords in C++ language. The total number of keywords is 63. Char, do, If struct float

Enge:Sajida Introduction to computing

Data types Data type defines a set of values and a set of operations of those values The data is given to the program as input The data is processed according to the program instruction and output is returned A C++ program may need to process different types of data Each data type require different amount of memory

Enge:Sajida Introduction to computing

Types of data type Integer data type Float data type Double data type Char data type

Enge:Sajida Introduction to computing

Integer data type A numeric value that has no decimal point or fraction It includes both positive and negative value Types of integers C++ provides different types of integer data Int Short int Long int Unsigned int Unsigned long int

Enge:Sajida Introduction to computing

Int data type Is used to store integer values It takes two or four bytes in memory It takes two bytes and its range is from -32768 to 32767 Unsigned int data type Is used to store the positive integer values It takes two bytes in memory Its range is from 0 to 65,535

Enge:Sajida Introduction to computing

Unsigned long integer data type Is used to store positive integer values It takes four bytes in memory its range is from 0 to 4,294967295 Long integer data type Long integer data type is used to store large integer value It takes 4 bytes in memory Its range is from 2,147,483648 to 2,147,483,647 Short int data type Is used to store integer value It takes two bytes in memory Its range is from o to 65,535
Enge:Sajida Introduction to computing

Real data type Real data type is numeric value with decimal point or fraction It is also called floating point number It includes both positive number and negative number Example are 10.5,-10.91 Types Float Long float Double long double
Enge:Sajida Introduction to computing

Float data type Float data type is used to store real values It takes four bytes in memory Its range is from 3.4*1038 to 3.4*10-38 Double data type Double data type is used to store large real values It takes 8 bytes in memory Its range is from 1.7*10-308 to 1.7*10308 It provides accuracy of 15 decimal places

Enge:Sajida Introduction to computing

Long double data type Long double data type is used to store very large real values It takes 10 bytes in memory its range is from 1.7*10-4932 to 1.7*10 4932 it provides accuracy of 19 decimal places

Enge:Sajida Introduction to computing

Character data type


Char data type is used to store char value It takes one byte in memory It is used to represent a letter, number, or punctuation mark and a few other symbols Character values is normally given in single quotes It can represent individually characters such as a,x,5 Character 5 is treated differently than integer 5 The key word signed and unsigned can be used char data type The signed character can represent number from 127 to -128 The unsigned characters can represent number from 0 to 255

Enge:Sajida Introduction to computing

Integer over flow and under flow Integer overflow occurs when the value assigned to an integer variable is more than its maximum possible value Integer underflow occurs when the value is assigned to an integer is less than possible minimum value

Enge:Sajida Introduction to computing

Variables A variable is a named memory location or memory cell It is used to store programs input data and its computational results during execution The value of a variable is changed during the execution of program The value stored in a variable is referred by variable name The variables are created in RAM Data stored in variable is temporary It can be used and processed during the execution of the program The data stored in the variables is automatically removed when program ends
Enge:Sajida Introduction to computing

The value of a variable is changed during program execution but its name will remain same
Name of variable Location of variable Computer memory Marks 10

Enge:Sajida Introduction to computing

Variables declaration The process of specifying the variable name and its type is called variable declaration All variable must be declared before they are used in the program Compiler uses the declaration to determine how much memory is needed for each variable Different type of variables require different amount of memory The required number of bytes are allocated when a variable is declared

Enge:Sajida Introduction to computing

Syntax The syntax of declaring variable is as follows Data- type variable-name ; Data type it indicates type of data that can be stored in variable Variable name refers to memory location of the variable Int marks; float avg; Double salary;

Enge:Sajida Introduction to computing

Variable initialization The process of assigning a value to a variable at the time of declaration The equal sign is used to initialize a variable Syntax Type name variable = value ; Type name indicates the data type of the variable to be initialized Variable name of the variable to be initialized = assignment operator Value it is the value to initialize a variable Int n =100;

Enge:Sajida Introduction to computing

Constant Constant is the quantity that cannot be change during the program execution Types Literal constant Symbolic constant Literal constant is a value that is typed directly in the program It appears in the program where it is needed Hello world is string literal constant

Enge:Sajida Introduction to computing

Types of literal constants Integer constant Floating point constant Character constant String constant

Enge:Sajida Introduction to computing

Symbolic constant A symbolic constant is a name given to the values that can no be changed Symbolic constants are used to represent a value that is frequently used in the program Types of symbolic constant Const qualifier Define Directive

Enge:Sajida Introduction to computing

Const Qualifier Const qualifier is used to define a constant Const is declared by its name and its data type The const must be initialized with some value the initialized value can not be changed during the program execution Syntax Const data type identifier=value; Const int N=100;

Enge:Sajida Introduction to computing

Define directive Also used to define a constant It does not specify the data type of the constant Define directive starts with # symbol It is not terminated with semicolon Syntax #define identifier value # starts of preprocessor directive Define used to define a constant Identifier it is the name of constant Value it represents the value associated with the identifier #define PI3.141593
Enge:Sajida Introduction to computing

You might also like