SlideShare ist ein Scribd-Unternehmen logo
1 von 13
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

Weitere ähnliche Inhalte

Was ist angesagt?

Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
Tony Apreku
 

Was ist angesagt? (20)

Presentation on c structures
Presentation on c   structures Presentation on c   structures
Presentation on c structures
 
Variables and data types in C++
Variables and data types in C++Variables and data types in C++
Variables and data types in C++
 
Data types in C
Data types in CData types in C
Data types in C
 
Lect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer AbbasLect 9(pointers) Zaheer Abbas
Lect 9(pointers) Zaheer Abbas
 
Constant and variacles in c
Constant   and variacles in cConstant   and variacles in c
Constant and variacles in c
 
Basic Data Types in C++
Basic Data Types in C++ Basic Data Types in C++
Basic Data Types in C++
 
Data Types and Variables In C Programming
Data Types and Variables In C ProgrammingData Types and Variables In C Programming
Data Types and Variables In C Programming
 
Data types
Data typesData types
Data types
 
Constant, variables, data types
Constant, variables, data typesConstant, variables, data types
Constant, variables, data types
 
Data types
Data typesData types
Data types
 
Introduction to data structure
Introduction to data structureIntroduction to data structure
Introduction to data structure
 
Data types and Operators
Data types and OperatorsData types and Operators
Data types and Operators
 
Data Type in C Programming
Data Type in C ProgrammingData Type in C Programming
Data Type in C Programming
 
data types in C programming
data types in C programmingdata types in C programming
data types in C programming
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
Data types in C
Data types in CData types in C
Data types in C
 
Java: Primitive Data Types
Java: Primitive Data TypesJava: Primitive Data Types
Java: Primitive Data Types
 
Tokens in C++
Tokens in C++Tokens in C++
Tokens in C++
 
Data types
Data typesData types
Data types
 

Andere mochten auch (10)

Redo midterm
Redo midtermRedo midterm
Redo midterm
 
Csc1100 lecture01 ch01-pt1
Csc1100 lecture01 ch01-pt1Csc1100 lecture01 ch01-pt1
Csc1100 lecture01 ch01-pt1
 
Digital That Delivers: Strategies You Should Implement Now
Digital That Delivers: Strategies You Should Implement NowDigital That Delivers: Strategies You Should Implement Now
Digital That Delivers: Strategies You Should Implement Now
 
SamXinRomeShow
SamXinRomeShowSamXinRomeShow
SamXinRomeShow
 
Mule cloud connectors versus el resto del mundo
Mule cloud connectors versus el resto del mundoMule cloud connectors versus el resto del mundo
Mule cloud connectors versus el resto del mundo
 
Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009Visual sceneperception encycloperception-sage-oliva2009
Visual sceneperception encycloperception-sage-oliva2009
 
Psychology cs
Psychology   csPsychology   cs
Psychology cs
 
Principle and Practice of Management MGT Ippt chap014
Principle and Practice of Management MGT Ippt chap014Principle and Practice of Management MGT Ippt chap014
Principle and Practice of Management MGT Ippt chap014
 
Tutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seoTutorial import n auto pilot blogspot friendly seo
Tutorial import n auto pilot blogspot friendly seo
 
VOLUME, 6th std., Learning material
VOLUME, 6th std., Learning materialVOLUME, 6th std., Learning material
VOLUME, 6th std., Learning material
 

Ähnlich wie Oop l3n

Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
ssuser5610081
 
C Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptxC Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptx
Murali M
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
atifmugheesv
 

Ähnlich wie Oop l3n (20)

Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
Data Types in C++-Primary or Built-in or Fundamental data type Derived data t...
 
Lec9
Lec9Lec9
Lec9
 
5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt5-Lec - Datatypes.ppt
5-Lec - Datatypes.ppt
 
C PROGRAMMING LANGUAGE.pptx
 C PROGRAMMING LANGUAGE.pptx C PROGRAMMING LANGUAGE.pptx
C PROGRAMMING LANGUAGE.pptx
 
Cp presentation
Cp presentationCp presentation
Cp presentation
 
Chapter 2.datatypes and operators
Chapter 2.datatypes and operatorsChapter 2.datatypes and operators
Chapter 2.datatypes and operators
 
Basic Concepts of C Language.pptx
Basic Concepts of C Language.pptxBasic Concepts of C Language.pptx
Basic Concepts of C Language.pptx
 
Module 1:Introduction
Module 1:IntroductionModule 1:Introduction
Module 1:Introduction
 
C programming basic concepts of mahi.pptx
C programming basic concepts of mahi.pptxC programming basic concepts of mahi.pptx
C programming basic concepts of mahi.pptx
 
C Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptxC Programming Lecture 3 - Elements of C.pptx
C Programming Lecture 3 - Elements of C.pptx
 
Chapter 2: Elementary Programming
Chapter 2: Elementary ProgrammingChapter 2: Elementary Programming
Chapter 2: Elementary Programming
 
Aniket tore
Aniket toreAniket tore
Aniket tore
 
Data types
Data typesData types
Data types
 
Data Handling
Data HandlingData Handling
Data Handling
 
Lecture 2
Lecture 2Lecture 2
Lecture 2
 
variablesfinal-170820055428 data type results
variablesfinal-170820055428 data type resultsvariablesfinal-170820055428 data type results
variablesfinal-170820055428 data type results
 
C introduction
C introductionC introduction
C introduction
 
unit2.pptx
unit2.pptxunit2.pptx
unit2.pptx
 
an introduction to c++ templates-comprehensive guide.ppt
an introduction to c++ templates-comprehensive guide.pptan introduction to c++ templates-comprehensive guide.ppt
an introduction to c++ templates-comprehensive guide.ppt
 
Typescript: Beginner to Advanced
Typescript: Beginner to AdvancedTypescript: Beginner to Advanced
Typescript: Beginner to Advanced
 

Kürzlich hochgeladen

Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
ZurliaSoop
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
heathfieldcps1
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
KarakKing
 

Kürzlich hochgeladen (20)

Graduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - EnglishGraduate Outcomes Presentation Slides - English
Graduate Outcomes Presentation Slides - English
 
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
Sensory_Experience_and_Emotional_Resonance_in_Gabriel_Okaras_The_Piano_and_Th...
 
How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17How to Add New Custom Addons Path in Odoo 17
How to Add New Custom Addons Path in Odoo 17
 
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptxHMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
HMCS Vancouver Pre-Deployment Brief - May 2024 (Web Version).pptx
 
Micro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdfMicro-Scholarship, What it is, How can it help me.pdf
Micro-Scholarship, What it is, How can it help me.pdf
 
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
Beyond_Borders_Understanding_Anime_and_Manga_Fandom_A_Comprehensive_Audience_...
 
Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17How to Create and Manage Wizard in Odoo 17
How to Create and Manage Wizard in Odoo 17
 
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptxBasic Civil Engineering first year Notes- Chapter 4 Building.pptx
Basic Civil Engineering first year Notes- Chapter 4 Building.pptx
 
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
Jual Obat Aborsi Hongkong ( Asli No.1 ) 085657271886 Obat Penggugur Kandungan...
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
General Principles of Intellectual Property: Concepts of Intellectual Proper...
General Principles of Intellectual Property: Concepts of Intellectual  Proper...General Principles of Intellectual Property: Concepts of Intellectual  Proper...
General Principles of Intellectual Property: Concepts of Intellectual Proper...
 
Python Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docxPython Notes for mca i year students osmania university.docx
Python Notes for mca i year students osmania university.docx
 
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptxExploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
Exploring_the_Narrative_Style_of_Amitav_Ghoshs_Gun_Island.pptx
 
Key note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdfKey note speaker Neum_Admir Softic_ENG.pdf
Key note speaker Neum_Admir Softic_ENG.pdf
 
ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.ICT role in 21st century education and it's challenges.
ICT role in 21st century education and it's challenges.
 
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
NO1 Top Black Magic Specialist In Lahore Black magic In Pakistan Kala Ilam Ex...
 
The basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptxThe basics of sentences session 3pptx.pptx
The basics of sentences session 3pptx.pptx
 
Salient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functionsSalient Features of India constitution especially power and functions
Salient Features of India constitution especially power and functions
 
How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17How to Give a Domain for a Field in Odoo 17
How to Give a Domain for a Field in Odoo 17
 

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