SlideShare a Scribd company logo
Tokens, Expressions and
Control Structures
Dr. Mohammad Shahidul Islam
AP, IIT, JU
1
3.2 Tokens
• the smallest individual units in a program are
known as tokens.
• Eg:
• Keywords
• Identifiers
• Constants
• Strings
• Operators
• Usually program is written using these tokens,
white spaces, and the syntax of the language.
2
3.3 Keywords
• They are explicitly reserved identifier and
• cannot be used as names for the program
variables or
• other user-defined program elements.
• Some examples:
• If
• Else
• Void
• Int etc.
3
3.4 Identifiers and Constants
• Identifiers refer to the names of variables,
functions, arrays, classes, etc. created by the
programmer.
• They are the fundamental requirement of any
language,
• Each language has its own rules for naming
these identifiers.
4
Constants
• Constant refer to fixed values that do out
change during the execution of a program.
• They include integers, characters, floating
point numbers and strings. Eg.
– 123 integer const
– 123.21 Floating point
– “A” character const
5
3.5 Basic Data Types
• Data types in C++ can be classified under
various categories as shown in Fig. 3.1,
6
Cont.
• Compilers needs to support the language data
types, known as basic or fundamental data
types
• the basic data types may have several
modifiers preceding them to serve the needs
of various situations.
• modifiers like: ‘signed’, ‘unsigned’, ‘long’, and
‘short’ may be applied to character and
integer basic/fundamental data types,
7
Fundamental data types and their
ranges
8
3.6 User-Defined Data Types
• user-defined data type known as class which can
be used, just like any other basic data type, to
declare variables.
• The class variables are known as objects, which are
the central focus of object-oriented programming,
class person
{
char name[30];
int age;
public:
void getdata(void);
void display(void);
};
public class Dog
{
String breed;
int age;
String color;
void barking(){ }
void hungry(){ }
void sleeping(){ }
}
9
Enumerated Data Type
• An enumerated data type is another user-
defined type which provides a way for
attaching names to numbers,
– enum shape(circle, square, triangle);
– enum colour(red. blue, green, yellow);
10
Arrays, functions and pointers
• the application of arrays in C++ is similar to
that in C.
• When initializing a character array in ANSI C,
the compiler will allow us to declare the array
size as the exact length of the string constant.
E.g.:
– char string[3] = "xyz";
• in C++, the size should be one larger than the
number of characters in the string.
11
functions
• Concept of functions has changed a lot from C
to C++.
• The is to cope up with the OOP.
• This makes the program more reliable and
readable.
12
pointers
• The concept of functions has also changed a
lot from C to C++.
• As C++ is an OOP language, its adds the
concept of constant pointer and pointer to a
constant.
• E.g:
• char * const p1= "GOOD"; // constant pointer
• char const * p1= "GOOD"; // pointer to
constant
13

More Related Content

PPTX
Variables in C++, data types in c++
PPTX
Programming construction tools
PPTX
Introduction to c++
PPT
3 data-types-in-c
PPTX
Concept of c data types
PPTX
Structures in c language
PPT
constants, variables and datatypes in C
PPTX
Datatype in c++ unit 3 -topic 2
Variables in C++, data types in c++
Programming construction tools
Introduction to c++
3 data-types-in-c
Concept of c data types
Structures in c language
constants, variables and datatypes in C
Datatype in c++ unit 3 -topic 2

What's hot (20)

PPTX
Presentation on c structures
PPTX
Variables and data types in C++
PPTX
Data types in C
PPT
Lect 9(pointers) Zaheer Abbas
PPTX
Constant and variacles in c
PPTX
Basic Data Types in C++
PPTX
Data Types and Variables In C Programming
PPTX
Data types
PPTX
Constant, variables, data types
PPTX
Data types
PPTX
Introduction to data structure
PPT
Data types and Operators
PPTX
Data Type in C Programming
PPTX
data types in C programming
PPTX
Variables in C and C++ Language
PPTX
Lecture 2 variables
PPTX
Data types in C
PPT
Java: Primitive Data Types
PPTX
Tokens in C++
PPTX
Data types
Presentation on c structures
Variables and data types in C++
Data types in C
Lect 9(pointers) Zaheer Abbas
Constant and variacles in c
Basic Data Types in C++
Data Types and Variables In C Programming
Data types
Constant, variables, data types
Data types
Introduction to data structure
Data types and Operators
Data Type in C Programming
data types in C programming
Variables in C and C++ Language
Lecture 2 variables
Data types in C
Java: Primitive Data Types
Tokens in C++
Data types
Ad

Viewers also liked (10)

PDF
Redo midterm
PPT
Csc1100 lecture01 ch01-pt1
PPTX
Digital That Delivers: Strategies You Should Implement Now
PPTX
SamXinRomeShow
PPTX
Mule cloud connectors versus el resto del mundo
PDF
Visual sceneperception encycloperception-sage-oliva2009
DOC
Psychology cs
PPTX
Principle and Practice of Management MGT Ippt chap014
PDF
Tutorial import n auto pilot blogspot friendly seo
PPSX
VOLUME, 6th std., Learning material
Redo midterm
Csc1100 lecture01 ch01-pt1
Digital That Delivers: Strategies You Should Implement Now
SamXinRomeShow
Mule cloud connectors versus el resto del mundo
Visual sceneperception encycloperception-sage-oliva2009
Psychology cs
Principle and Practice of Management MGT Ippt chap014
Tutorial import n auto pilot blogspot friendly seo
VOLUME, 6th std., Learning material
Ad

Similar to Oop l3n (20)

PDF
C++ PPT IN NUMERICAL METHOD FOR M.Sc PHYSICS
PPT
5-Lec - Datatypes.ppt
PPTX
Data types
PDF
Keywords, identifiers ,datatypes in C++
PDF
Introduction to c++
PPTX
OODP Unit 1 OOPs classes and objects
PPTX
OOPS (object oriented programming) unit 1
PPT
Key Concepts of C++ computer language.ppt
PDF
Introduction to c++ ppt
PPTX
introductiontocprogramming datatypespp.pptx
PDF
2 expressions (ppt-2) in C++
PDF
Introduction of C++ By Pawan Thakur
PDF
chap3expression-1603gggh13040831 (1).pdf
PPTX
expression in cpp
PPTX
expression in cpp
PPTX
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTRE
PDF
4.-C-Tokens.pdf.Cpp tockens.where are they use
PPT
Basics of c++ Programming Language
PPTX
Introduction to c++ programming language
PPTX
Chap_________________1_Introduction.pptx
C++ PPT IN NUMERICAL METHOD FOR M.Sc PHYSICS
5-Lec - Datatypes.ppt
Data types
Keywords, identifiers ,datatypes in C++
Introduction to c++
OODP Unit 1 OOPs classes and objects
OOPS (object oriented programming) unit 1
Key Concepts of C++ computer language.ppt
Introduction to c++ ppt
introductiontocprogramming datatypespp.pptx
2 expressions (ppt-2) in C++
Introduction of C++ By Pawan Thakur
chap3expression-1603gggh13040831 (1).pdf
expression in cpp
expression in cpp
C++ Langauage Training in Ambala ! BATRA COMPUTER CENTRE
4.-C-Tokens.pdf.Cpp tockens.where are they use
Basics of c++ Programming Language
Introduction to c++ programming language
Chap_________________1_Introduction.pptx

Recently uploaded (20)

PDF
What if we spent less time fighting change, and more time building what’s rig...
PPTX
Cell Types and Its function , kingdom of life
PPTX
A powerpoint presentation on the Revised K-10 Science Shaping Paper
PPTX
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
PPTX
History, Philosophy and sociology of education (1).pptx
PDF
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PDF
Complications of Minimal Access Surgery at WLH
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
PDF
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
PPTX
Orientation - ARALprogram of Deped to the Parents.pptx
PDF
Computing-Curriculum for Schools in Ghana
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PDF
Chinmaya Tiranga quiz Grand Finale.pdf
PDF
Indian roads congress 037 - 2012 Flexible pavement
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PDF
Classroom Observation Tools for Teachers
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PPTX
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
What if we spent less time fighting change, and more time building what’s rig...
Cell Types and Its function , kingdom of life
A powerpoint presentation on the Revised K-10 Science Shaping Paper
Chinmaya Tiranga Azadi Quiz (Class 7-8 )
History, Philosophy and sociology of education (1).pptx
A GUIDE TO GENETICS FOR UNDERGRADUATE MEDICAL STUDENTS
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Complications of Minimal Access Surgery at WLH
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
احياء السادس العلمي - الفصل الثالث (التكاثر) منهج متميزين/كلية بغداد/موهوبين
Orientation - ARALprogram of Deped to the Parents.pptx
Computing-Curriculum for Schools in Ghana
Paper A Mock Exam 9_ Attempt review.pdf.
Chinmaya Tiranga quiz Grand Finale.pdf
Indian roads congress 037 - 2012 Flexible pavement
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Classroom Observation Tools for Teachers
Final Presentation General Medicine 03-08-2024.pptx
Tissue processing ( HISTOPATHOLOGICAL TECHNIQUE
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3

Oop l3n

  • 1. Tokens, Expressions and Control Structures Dr. Mohammad Shahidul Islam AP, IIT, JU 1
  • 2. 3.2 Tokens • the smallest individual units in a program are known as tokens. • Eg: • Keywords • Identifiers • Constants • Strings • Operators • Usually program is written using these tokens, white spaces, and the syntax of the language. 2
  • 3. 3.3 Keywords • They are explicitly reserved identifier and • cannot be used as names for the program variables or • other user-defined program elements. • Some examples: • If • Else • Void • Int etc. 3
  • 4. 3.4 Identifiers and Constants • Identifiers refer to the names of variables, functions, arrays, classes, etc. created by the programmer. • They are the fundamental requirement of any language, • Each language has its own rules for naming these identifiers. 4
  • 5. Constants • Constant refer to fixed values that do out change during the execution of a program. • They include integers, characters, floating point numbers and strings. Eg. – 123 integer const – 123.21 Floating point – “A” character const 5
  • 6. 3.5 Basic Data Types • Data types in C++ can be classified under various categories as shown in Fig. 3.1, 6
  • 7. Cont. • Compilers needs to support the language data types, known as basic or fundamental data types • the basic data types may have several modifiers preceding them to serve the needs of various situations. • modifiers like: ‘signed’, ‘unsigned’, ‘long’, and ‘short’ may be applied to character and integer basic/fundamental data types, 7
  • 8. Fundamental data types and their ranges 8
  • 9. 3.6 User-Defined Data Types • user-defined data type known as class which can be used, just like any other basic data type, to declare variables. • The class variables are known as objects, which are the central focus of object-oriented programming, class person { char name[30]; int age; public: void getdata(void); void display(void); }; public class Dog { String breed; int age; String color; void barking(){ } void hungry(){ } void sleeping(){ } } 9
  • 10. Enumerated Data Type • An enumerated data type is another user- defined type which provides a way for attaching names to numbers, – enum shape(circle, square, triangle); – enum colour(red. blue, green, yellow); 10
  • 11. Arrays, functions and pointers • the application of arrays in C++ is similar to that in C. • When initializing a character array in ANSI C, the compiler will allow us to declare the array size as the exact length of the string constant. E.g.: – char string[3] = "xyz"; • in C++, the size should be one larger than the number of characters in the string. 11
  • 12. functions • Concept of functions has changed a lot from C to C++. • The is to cope up with the OOP. • This makes the program more reliable and readable. 12
  • 13. pointers • The concept of functions has also changed a lot from C to C++. • As C++ is an OOP language, its adds the concept of constant pointer and pointer to a constant. • E.g: • char * const p1= "GOOD"; // constant pointer • char const * p1= "GOOD"; // pointer to constant 13