3. INTRODUCTION
C++ IS A PROGRAMMING LANGUAGE
DEVELOPED BY BJARNE STROUSTRUP
IN EARLY 1980’S
AT AT&T BELL LABORATORIES, USA.
AAKASH KAUSHIK
9891983083,9289817971
4. LANGUAGE
Language is way to communicate with each
other
AAKASH KAUSHIK
9891983083,9289817971
5. PROGRAM
A PROGRAM IS A SET/SEQUENCE OF
COMMANDS
AAKASH KAUSHIK
9891983083,9289817971
6. COMPUTER LANGUAGE AND MACHINE
LANGUAGE
BINARY LANGUAGE/MACHINE LANGUAGE/LOW
LEVEL LANGUAGE
Computer is an electronic device at its core level
it works on Binary Language i.e., 0,1 or high &
low. Everything in computer is stored in LLL.
HIGH LEVEL LANGUAGE
Programming languages like JAVA,C,C++ are
called HLL. Code of all these language are
written in English language.
AAKASH KAUSHIK
9891983083,9289817971
7. LANGUAGE PROCESSORS
ASSEMBLOR- Converts Assembly language into
machine language
INTERPRETER-Converts HLL to LLL and vice
versa. It performs conversion in line by line
manner and notifies if any error is detected &
stops it’s conversion until that error is rectified
COMPILER-Converts HLL to LLL and vice versa.
It converts the whole program in one go and
notifies all the errors at the same time
AAKASH KAUSHIK
9891983083,9289817971
8. C++ CHARACTER SET
Character sets are the characters used to write a
language.
Characters A-Z, a-z.
Digits 0-9.
Special Symbols {} [] () ; : “ ‘ < > ? & # ~ | / etc.
White spaces, new line characters .
Besides all these C++ has 256 ASCII characters.
ASCII- American Standard Code for Information
Interchange AAKASH KAUSHIK
9891983083,9289817971
9. TOKENS/LEXICAL UNITS
When the compiler is processing the source code of
a program, each group of characters separated by
white spaces is called a token.
AAKASH KAUSHIK
9891983083,9289817971
10. C++ Allows 5 Types Of
Tokens
1. KEYWORDS
2. IDENTIFIERS
3. LITERALS/CONSTANTS
4. PUNTUATORS/SEPARATORS
5. OPERATORS
AAKASH KAUSHIK
9891983083,9289817971
11. KEYWORDS
KEYWORDS ( also known as specially reserved
words) CONVEYS A SPECIAL MEANING TO
COMPILER.
KEYWORDS are always typed in short(lower)
case.
They are reserved by the language for special
purpose and can’t be redefined as an
IDENTIFIER.
AAKASH KAUSHIK
9891983083,9289817971
13. IDENTIFIERS
IDENTIFIERS ARE THE NAMES GIVEN BY
THE PROGRAMMER TO DIFFERENT BLOCKS,
PARTS OF A PROGRAM TO IDENTIFY THEM.
AAKASH KAUSHIK
9891983083,9289817971
14. RULES/CONVENTIONS FOR
DEFINING IDENTIFIERS
It can contain characters(A-Z, a-z),Digits(0-
9), & only one special symbol called
underscore(_).
First letter must be a character (A-Z, a-z) or
underscore(_).
No commas or blank spaces allowed.
C++ IS A CASE SENSITIVE LANGUAGE i.e.,
Upper case and Lower case characters are
different.
AAKASH KAUSHIK
9891983083,9289817971
15. LITERALS/CONSTANTS
LITERALS AND CONSTANTS ARE THOSE
TOKENS WHOSE VALUES DON’T CHANGE
DURING THE PROGRAM EXECUTION.
AAKASH KAUSHIK
9891983083,9289817971
16. LITERALS/CONSTANTS
INTEGER CONSTANT
complete rounded off numbers are called integer constants for ex :-
540, 2, 98 etc.
REAL/FLOAT CONSTANTS
Numbers with decimal point are called Real/Float literals for ex :-
2.5, 0.54, 45.98 etc.
CHARACTER CONSTANTS
Single character enclosed within single quotes(‘ ’) are called
character constants for ex :- ‘A’, ‘B’, ‘d’ etc.
STRING CONSTANTS
Group of characters enclosed within double quotes(“ “) are called
string literals for ex :- “programming” “language” etc.
AAKASH KAUSHIK
9891983083,9289817971
17. PUNTUATORS/SEPARATORS
PUNTUATORS ARE USED TO SEPARATE TOKENS
WITHIN A PROGRAM. THE VARIOUS
PUNUATORS ARE:
{} [] () : ; , etc.
AAKASH KAUSHIK
9891983083,9289817971
18. OPERATORS
OPERATORS OPERATES ON SOME DATA TO
GIVE RESULTS
For ex :- A+B=C
Here A, B are operand and + is the operator
which produces C as a result of addition of A
and B.
AAKASH KAUSHIK
9891983083,9289817971
19. OPERATORS
Various operators in C++ are
Arithmetic operators
+,-,*,/,%
Relational operators
Logical operators
Increment/Decrement Operators
Conditional Operators
We will discuss operators in depth later in Unit-4
Operators & expressions.
AAKASH KAUSHIK
9891983083,9289817971