computer science tokens in c++ for school students
DevipriyaRajendran1
22 views
18 slides
May 08, 2024
Slide 1 of 18
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
About This Presentation
Tokens in c++
Size: 568.34 KB
Language: en
Added: May 08, 2024
Slides: 18 pages
Slide Content
Name : R.Devipriya ReG. No : 1021719bd020 department: Computer science Class : XI
TOPIC ?
H ow do we construct C++ program?
TOPIC TOKENS IN C++
TOKENS Tokens are t h e basic building blocks in C++ language. T h e smallest individual units in a program are known as Tokens. A program is constructed using a combination of these tokens
C++ has following tokens
EXAMPLES: int , float, double, switch, break, c har, const, continue, default, for, if, static, void, sizeof , w h ile, return, long, do etc., KEYWORDS Definition: Sequence of characters t h at have fixed meaning. Keywords must be written in lower case Reserved identifiers and can’t be used as names for t h e 1) Program variables 2) user defined program elements
IDENTIFIERS It is the name given to a variable, function, array etc. These are the user defined names and consist of the sequence of the letters and digits with a letter as a first character .
EXAMPLES: Valid Identifiers Result Test2 _sum Power Invalid Identifiers Su-// containing special character '-'. 2data // the first letter is a digit. break // use of a keyword. NAMING CONVENTION Only alphabetic characters, digits, and underscores are allowed. The identifier name cannot start with a digit or a number C++ identifiers are case-sensitive. A declared keyword cannot be used as a variable name.
Is t his a VALID IDENTIFIER? Num&add
Num&add is A INVALID IDENTIFIER REASON: special c h aracter except underescore is not permitted
CONSTANTS Definition: T h e Quantities w h ose value do not c h an g e during t h e program execution are known CONSTANTS
STRINGS Definition: A group of characters t h at are treated as a single item data enclosed in double quotes are known as STRINGS General Syntax : char string-name[size]; Size determines t h e number of c h aracters in t h e string name Example : char country[9]= “ INDIA”;
Is t his a VALID STRIN G ? ‘ WELCOME ’
‘ WELCOME ’ is INVALID STRIN G REASON: Valid String should be enclosed within double quotes
PUNCTUATORS DEFINITION: Punctuators are symbols, which are used as delimiters, while constructing a C++ program. They are also called as “Separators ”.
Operators DEFINITION: An operator is a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators