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

What's hot (20)

PPTX
Presentation on c structures
topu93
 
PPTX
Variables and data types in C++
Ameer Khan
 
PPTX
Data types in C
Tarun Sharma
 
PPT
Lect 9(pointers) Zaheer Abbas
Information Technology Center
 
PPTX
Constant and variacles in c
yash patel
 
PPTX
Basic Data Types in C++
Hridoy Bepari
 
PPTX
Data Types and Variables In C Programming
Kamal Acharya
 
PPTX
Data types
Nokesh Prabhakar
 
PPTX
Constant, variables, data types
Pratik Devmurari
 
PPTX
Data types
Syed Umair
 
PPTX
Introduction to data structure
sunilchute1
 
PPT
Data types and Operators
raksharao
 
PPTX
Data Type in C Programming
Qazi Shahzad Ali
 
PPTX
data types in C programming
Harshita Yadav
 
PPTX
Variables in C and C++ Language
Way2itech
 
PPTX
Lecture 2 variables
Tony Apreku
 
PPTX
Data types in C
Satveer Mann
 
PPT
Java: Primitive Data Types
Tareq Hasan
 
PPTX
Tokens in C++
Mahender Boda
 
PPTX
Data types
Zahid Hussain
 
Presentation on c structures
topu93
 
Variables and data types in C++
Ameer Khan
 
Data types in C
Tarun Sharma
 
Lect 9(pointers) Zaheer Abbas
Information Technology Center
 
Constant and variacles in c
yash patel
 
Basic Data Types in C++
Hridoy Bepari
 
Data Types and Variables In C Programming
Kamal Acharya
 
Data types
Nokesh Prabhakar
 
Constant, variables, data types
Pratik Devmurari
 
Data types
Syed Umair
 
Introduction to data structure
sunilchute1
 
Data types and Operators
raksharao
 
Data Type in C Programming
Qazi Shahzad Ali
 
data types in C programming
Harshita Yadav
 
Variables in C and C++ Language
Way2itech
 
Lecture 2 variables
Tony Apreku
 
Data types in C
Satveer Mann
 
Java: Primitive Data Types
Tareq Hasan
 
Tokens in C++
Mahender Boda
 
Data types
Zahid Hussain
 

Viewers also liked (10)

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

Similar to Oop l3n (20)

PPTX
TAPASH kumar das its my college pptasjhk
destroyer7992
 
PPTX
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
ssuser5610081
 
PPTX
Lec9
kapil078
 
PDF
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
PPT
5-Lec - Datatypes.ppt
AqeelAbbas94
 
PPTX
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
PDF
Cp presentation
MeetaPrajapati
 
PPTX
Chapter 2.datatypes and operators
Jasleen Kaur (Chandigarh University)
 
PPTX
Basic Concepts of C Language.pptx
KorbanMaheshwari
 
PPTX
Module 1:Introduction
nikshaikh786
 
PPTX
C programming basic concepts of mahi.pptx
KorbanMaheshwari
 
PPTX
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
PPTX
Chapter 2: Elementary Programming
Eric Chou
 
PPTX
Basic of Structered Programming in C psd
YogaBalajee1
 
PPTX
Aniket tore
anikettore1
 
PPTX
Data types
Sachin Satwaskar
 
PPTX
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
PPT
Data Handling
Praveen M Jigajinni
 
PPTX
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
Muhammad Khubaib Awan
 
PPTX
Lecture 2
marvellous2
 
TAPASH kumar das its my college pptasjhk
destroyer7992
 
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
ssuser5610081
 
Lec9
kapil078
 
PROGRAMMING IN C UNIT II.pdfFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFFF
dinesh620610
 
5-Lec - Datatypes.ppt
AqeelAbbas94
 
C PROGRAMMING LANGUAGE.pptx
AnshSrivastava48
 
Cp presentation
MeetaPrajapati
 
Chapter 2.datatypes and operators
Jasleen Kaur (Chandigarh University)
 
Basic Concepts of C Language.pptx
KorbanMaheshwari
 
Module 1:Introduction
nikshaikh786
 
C programming basic concepts of mahi.pptx
KorbanMaheshwari
 
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
Chapter 2: Elementary Programming
Eric Chou
 
Basic of Structered Programming in C psd
YogaBalajee1
 
Aniket tore
anikettore1
 
Data types
Sachin Satwaskar
 
Best_of_438343817-A-PPT-on-C-language.pptx
nilaythakkar7
 
Data Handling
Praveen M Jigajinni
 
A Comprehensive Guide to C Programing Basics, Variable Declarations, Input/O...
Muhammad Khubaib Awan
 
Lecture 2
marvellous2
 
Ad

Recently uploaded (20)

PDF
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
PPTX
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
PPTX
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
PPTX
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
PPTX
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
PPTX
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
DOCX
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
PPTX
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
PPTX
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
PDF
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
PPTX
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
PPTX
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
PPTX
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
PPTX
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
PPT
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
PPTX
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
PDF
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
PDF
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
PDF
Virat Kohli- the Pride of Indian cricket
kushpar147
 
PPTX
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 
My Thoughts On Q&A- A Novel By Vikas Swarup
Niharika
 
I INCLUDED THIS TOPIC IS INTELLIGENCE DEFINITION, MEANING, INDIVIDUAL DIFFERE...
parmarjuli1412
 
Rules and Regulations of Madhya Pradesh Library Part-I
SantoshKumarKori2
 
CONCEPT OF CHILD CARE. pptx
AneetaSharma15
 
Command Palatte in Odoo 18.1 Spreadsheet - Odoo Slides
Celine George
 
LDP-2 UNIT 4 Presentation for practical.pptx
abhaypanchal2525
 
Modul Ajar Deep Learning Bahasa Inggris Kelas 11 Terbaru 2025
wahyurestu63
 
Cleaning Validation Ppt Pharmaceutical validation
Ms. Ashatai Patil
 
ENGLISH 8 WEEK 3 Q1 - Analyzing the linguistic, historical, andor biographica...
OliverOllet
 
BÀI TẬP TEST BỔ TRỢ THEO TỪNG CHỦ ĐỀ CỦA TỪNG UNIT KÈM BÀI TẬP NGHE - TIẾNG A...
Nguyen Thanh Tu Collection
 
Python-Application-in-Drug-Design by R D Jawarkar.pptx
Rahul Jawarkar
 
Continental Accounting in Odoo 18 - Odoo Slides
Celine George
 
Applications of matrices In Real Life_20250724_091307_0000.pptx
gehlotkrish03
 
TOP 10 AI TOOLS YOU MUST LEARN TO SURVIVE IN 2025 AND ABOVE
digilearnings.com
 
DRUGS USED IN THERAPY OF SHOCK, Shock Therapy, Treatment or management of shock
Rajshri Ghogare
 
PROTIEN ENERGY MALNUTRITION: NURSING MANAGEMENT.pptx
PRADEEP ABOTHU
 
EXCRETION-STRUCTURE OF NEPHRON,URINE FORMATION
raviralanaresh2
 
The-Invisible-Living-World-Beyond-Our-Naked-Eye chapter 2.pdf/8th science cur...
Sandeep Swamy
 
Virat Kohli- the Pride of Indian cricket
kushpar147
 
Artificial Intelligence in Gastroentrology: Advancements and Future Presprec...
AyanHossain
 

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