0% found this document useful (0 votes)
15 views12 pages

Introduction To C++ Programming

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
15 views12 pages

Introduction To C++ Programming

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 12

GETTING STARTED WITH C++

Character Set e

Fundamental unit of C++ language. Classified into


letters (a - z, A - Z), digits (0 - 9), special characters
(# , ; : > { + etc.), white spaces (space bar, tab, new
line) and some other characters whose ASCII code fall
in the range from 0 to 255.
-
Tokens

Tokens are the fundamental building blocks of the program. They


are also known as lexical units. C++ has five types of tokens as listed
-

below:

1. Keywords e
-
2. Identifiers
-
3. Literals
4. Punctuators
-
5. Operators -
Keywords e
The words (tokens) that convey a specific meaning to the language compiler
are called keywords. These are also known as reserved words .
Asm as a

E
0
Identifiers

Identifiers are the user-defined words that are used to name


-

different program elements such as memory locations, statements,


-

functions, objects, classes etc. The identifiers of memory


-

--
--

locations are called variables.


-
-

⑭ I
-
a
ab
Rules of Identifiers A-2
A -

09 -

e -

• Identifier is an arbitrary long sequence of letters, digits and


-

underscores ( _ ).
-• The first character must be a letter or underscore ( _ ).
- -
a• White space and special characters are not allowed.
-
a
• Keywords cannot be used as identifiers.
-

-• Upper and lower case letters are treated differently, i.e. C++ is
case sensitive.


adm

So -X
Literals e

-
Literals to represent data items that never change their value
-
during the program run.
They are often referred to as constants. Literals can be divided
-
into four types as follows:
1. Integer literals -
2. Floating point literals -
3. Character literals -
4. String literals e
Integer literals - 176, 707
Consider the numbers -1776, 707, -273. They are integer constants.
The tokens constituted only by digits are called integer literals and
they are whole numbers without fractional part.

Floating point literals -

Floating point literals, also known as real constants are numbers


having fractional parts. These can be written in one of the two
-

forms called fractional form or exponential form.

3.2 6.7
Character literals
When we refer a single character enclosed in single quotes that
-
-

never changes its value during the program run, we call it a


character literal or character constant.

Eg : ‘a’ , ‘1’ , ‘\n’ ,’\t’ , etc


al In

in
'in' it's
S
--
String Literals

A sequence of one or more characters enclosed within a pair of


double quotes is called string constant .
-

Eg : "Hello friends", "123", "C++", "Baby\'s Day Out", etc.


-

sa
19 I
abcall
Punctuators -

In the same way C++ also has some special symbols that have
-

syntactic or semantic meaning to the compiler. These are called


-
- -
-
punctuators. Examples are: # ; ‘ “ ( ) [ ] { }
-en
Operators -

An operator is a symbol that tells the compiler about a specific


-

operation.

IE
-

opens
+, -, -
-

As B,4 F-opseads
wor
6-7
Valid floating
point literals-
6-7E-2

-
6.7x1085

Is
X -

invalid
10-2 X floaters Dont
-56 x
Litezals
y

You might also like