NAME : R.DEVIPRIYA
REG. NO : 1021719BD020
DEPARTMENT: COMPUTER
SCIENCE
CLASS : XI
TOPIC
?
How do we
construct C++
program?
TOPIC
TOKENS IN C++
TOKENS
 Tokens are the basic building blocks in C++
language. The smallest individual units in a
program are known as Tokens.
 A program is constructed using a combination of
these tokens
 C++ has following tokens
TOKENS
Keywords Identifiers Constants String Operators Punctuators
EXAMPLES:
int, float, double,
switch, break,
char, const,
continue, default,
for, if, static, void,
sizeof, while,
return, long, do
etc.,
KEYWORDS
Definition:
Sequence of characters that have fixed meaning.
 Keywords must be written in lower case
 Reserved identifiers and can’t be used as
names for the
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.
Variables in C++
Numeric
Variables
To store either
integer values or
floating point values
Character
Variables
Albhabets and numbers
from 0-9 inserted
between single quotes
EXAMPLES:
Valid Identifiers
Result
Test2
_sum
Power
Invalid Identifiers
Su-
// containing special
character '-'.
2data // the first le
tter 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 this a VALID IDENTIFIER?
Num&add
Num&add is A INVALID
IDENTIFIER
REASON: special character
except underescore is not
permitted
CONSTANTS
Definition: The Quantities whose value do not
change during the program execution are
known CONSTANTS
STRINGS
 Definition:
A group of characters that are treated as a single item data
enclosed in double quotes are known as STRINGS
 General Syntax :
 char string-name[size];
 Size determines the number of characters in the string name
Example : char country[9]= “ INDIA”;
Is this a VALID STRING?
‘ WELCOME ’
‘ WELCOME ’ is INVALID
STRING
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
THANK YOU

computer science tokens in c++ for school students

  • 1.
    NAME : R.DEVIPRIYA REG.NO : 1021719BD020 DEPARTMENT: COMPUTER SCIENCE CLASS : XI
  • 2.
  • 3.
    How do we constructC++ program?
  • 4.
  • 5.
    TOKENS  Tokens arethe basic building blocks in C++ language. The smallest individual units in a program are known as Tokens.  A program is constructed using a combination of these tokens
  • 6.
     C++ hasfollowing tokens TOKENS Keywords Identifiers Constants String Operators Punctuators
  • 7.
    EXAMPLES: int, float, double, switch,break, char, const, continue, default, for, if, static, void, sizeof, while, return, long, do etc., KEYWORDS Definition: Sequence of characters that have fixed meaning.  Keywords must be written in lower case  Reserved identifiers and can’t be used as names for the 1) Program variables 2) user defined program elements
  • 8.
    IDENTIFIERS  It isthe 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. Variables in C++ Numeric Variables To store either integer values or floating point values Character Variables Albhabets and numbers from 0-9 inserted between single quotes
  • 9.
    EXAMPLES: Valid Identifiers Result Test2 _sum Power Invalid Identifiers Su- //containing special character '-'. 2data // the first le tter 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.
  • 10.
    Is this aVALID IDENTIFIER? Num&add
  • 11.
    Num&add is AINVALID IDENTIFIER REASON: special character except underescore is not permitted
  • 12.
    CONSTANTS Definition: The Quantitieswhose value do not change during the program execution are known CONSTANTS
  • 13.
    STRINGS  Definition: A groupof characters that are treated as a single item data enclosed in double quotes are known as STRINGS  General Syntax :  char string-name[size];  Size determines the number of characters in the string name Example : char country[9]= “ INDIA”;
  • 14.
    Is this aVALID STRING? ‘ WELCOME ’
  • 15.
    ‘ WELCOME ’is INVALID STRING REASON: Valid String should be enclosed within double quotes
  • 16.
    PUNCTUATORS  DEFINITION: Punctuators aresymbols, which are used as delimiters, while constructing a C++ program. They are also called as “Separators”.
  • 17.
    OPERATORS  DEFINITION: An operatoris a symbol that tells the compiler to perform specific mathematical or logical manipulations. C++ is rich in built-in operators
  • 18.