SlideShare una empresa de Scribd logo
1 de 26
Basic Object-
Oriented Concepts
By,
Shashikant pabari
Identifiers :
• They refer to the names of variables, function, array, classes
etc., created by the programmer.
• Each language has its own rules for naming these identifiers.
• Following are common rules for both C and C++:
o Only alphabetic characters, digit and underscores are
permitted.
o The name cannot start with a digit.
o Uppercase and lowercase letters are distinct.
o A declared keyword cannot be used as a variable name.
Some Examples of Identifier
Identifier Validity Reason
1digit Invalid Digit at first location is not allowed
digit-1 Invalid Special characters other than
underscore is not allowed
num 1 Invalid Space not allowed
num_1 Valid Underscore is valid identifier.
3
Constants :
• Constants refer to fixed values that do not change during
the execution of a program.
• They include integers, characters, floating point number
and strings.
• Literal constant do not have memory location.
• Ex :
• 123 // decimal integer
• 12.34 // floating point integer
• “c++” // string constant
• ‘A’ // character constant
4
Variable :
• A variable is the name for a place in the computer’s
memory where you store some data.
• Declaration of variable :
• A variable can be declared right at the place of its first use.
• This make the program much easier to write and reduces the errors
that may be caused by having to scan back and forth.
• It also make the program easier to understand because the
variables are declared in the context of their use.
• Ex :
float x; //declaration
int a; //declaration
5
Continue…
• Reference Variable :
• A new kind of variable known as the reference variable.
• A reference variable provides an alternative name for a previously
define variable.
• For example, If we make the variable sum a reference to the
variable total, then sum and total can be used interchangeable to
represent that variable.
• Syntax :
data-type & reference-name = variable-name
Ex:
float total = 50;
float & sum = total;
6
Operators :
• An operator is a symbol that tells the compiler to perform certain
mathematical or logical operation.
1. Arithmetic Operators :
o Arithmetic operators are used for mathematical calculation.
o Arithmetic operators are +, -, *, /, and %.
1. Relation operators :
o used to compare two numbers and taking decisions based on their
relation.
o Relation operators are <, <=, >, >=, ==, and != .
1. Logical operators:
o Used to test more than one condition and make decisions.
o Logical operators are &&, ||, and !.
7
Continue…
4. Assignment operators :
o Used to assign the result of an expression to a variable.
o Assignment operators are =, +=, -=, *=, /=, and %=.
5. Increment operators :
o These are special operators in c++.
o Increment operators are ++, and --.
6. Conditional operators:
o A ternary operator is known as conditional operators.
o Ex : x = (a>b) ? a : b; which is same as
if(a>b)
x=a;
else x=b;
8
Continue…
7. Bitwise operator :
o Used to perform operators bit by bit and may not be applied to
float or double.
o Bitwise operators are &, |, ^, <<, and >>.
8. Special operators :
o Special operators are
& is used to determine address of the variable.
* is used declare a pointer variable and to get value from it.
‘ is used to link the related expression together.
. is used in structure.
-> is used in pointer to structure.
9
Continue…
9. Extraction operators (>>) :
o Is used with cin to input data from keyboard.
10. Insertion operators (<<) :
o Is used with cout to output data from keyboard.
11. Scope resolution operators (::)
o It can be used in constructing programs. We know that the same
variable name can be used to have different meanings in different
blocks.
o Ex : int m=10;
{ int m=20; Output : m = 20
cout << “m” << m; ::m = 10
cout << “::m” << ::m;
}
10
Type Casting :
• It is used to convert the type of a variable, function, object,
expression or return value to another type.
• Type casting can also done using some typecast operators
available in c++.
• Static_cast operator : The static_cast keyword can be used for any
normal conversion between types. Conversions that rely on static
(compile-time) type information.
• Syntax : Static_cast <type> (object).
• Const_cast operator : The const_cast keyword can be used to remove
the const or volatile property from an object.
• Syntax : const_cast <type> (object).
11
Continue…
• Reinterpret_cast operator : The reinterpret_cast keyword is used
to simply cast one type bitwise to another. Any pointer or integral
type can be cast to any other with reinterpret cast, easily allowing
for misuse.
• Syntax : reinterpret_cast <type> (object).
• Dynamic_cast operator : The dynamic_cast keyword is used to
casts a datum from one pointer or reference of a polymorphic type
to another, similar to static_cast but performing a type safety check
at runtime to ensure the validity of the cast.
• Syntax : dynamic_cast <type> (object).
12
Continue…
• Example :
Main()
{
double a = 21.09399;
float b = 10.20;
int c;
c = int (a);
cout << “value of int(a) is :” << c << endl;
c = int (b);
cout << “value of int(b) is :” << c << endl;
return 0;
}
Output : value of int(a) is : 21
value of int(b) is : 10
13
Enumerated Data Type :
• An enumerated data type is another user-defined type which
provides a way for attaching names to numbers, thereby
increasing comprehensibility of the code.
• The enum keyword (from c) automatically enumerates a list of
words by assigning them values 0,1,2, and so on.
• This facility provides an alternative means for creative symbolic
comstants.
• The syntax of an enum statement is similar to that of the struct
statement.
• Ex : enum shape {circle, square, triangle}
enum colour {red, blue, green, yellow}
enum position {off, on}
14
Control Structures
• A large number of function are used that pass messages,
and process the data contained in objects.
• A function is set to perform a task. when the task is
complex, many different algorithms can be designed to
achieve the same goal. Some are simple to comprehend,
while others are not.
• The format should be such that it is easy to trace the flow of
execution of statements.
• Control structure tells about the order in which the
statement are executed and helps to perform manipulative,
repetitive and decision making actions.
• It can be used in three ways :
15
Continue…
1) Sequence structure (straight line)
2) Selection structure (branching)
3) Loop structure (iteration or repetition)
• Basic control structures
16(a) Sequence (b) Selection (c) Loop
Continue…
• Selection Structure (Branching Statements) :
• if statement.
• if-else statement.
• switch statement.
• goto statement.
• Loop structure (iteration or repetition) :
• While statement.
• Do-while statement.
• For statement.
if Selection Structure
• Selection structure
• Choose among alternative courses of action
• Pseudocode example:
If student’s grade is greater than or equal to 60
Print “Passed”
• If the condition is true
• Print statement executed, program continues to next
statement
• If the condition is false
• Print statement ignored, program continues
• Indenting makes programs easier to read
• C++ ignores whitespace characters (tabs, spaces, etc.)
• Translation into C++
If student’s grade is greater than or equal to 60
Print “Passed”
if ( grade >= 60 )
cout << "Passed";
• if structure
• Single-entry/single-exit
true
false
grade >= 60 print “Passed”
if/else Selection Structure
• if
• Performs action if condition true
• if/else
• Different actions if conditions true or false
• Pseudocode
if student’s grade is greater than or equal to 60
print “Passed”
else
print “Failed”
• C++ code
if ( grade >= 60 )
cout << "Passed";
else
cout << "Failed";
20
Example
if ( grade >= 90 ) // 90
and above
cout << "A";
else if ( grade >= 80 ) // 80-89
cout << "B";
else if ( grade >= 70 ) // 70-79
cout << "C";
else if ( grade >= 60 ) // 60-69
cout << "D";
else // less than
60
cout << "F";
21
Switch Case
• switch
• Test variable for multiple values
• Series of case labels and optional default case
switch ( variable ) {
case value1: // taken if variable == value1
statements
break; // necessary to exit switch
case value2:
case value3: // taken if variable == value2 or == value3
statements
break;
default: // taken if variable matches no other cases
statements
break;
}
22
While loop
23
sample <= 2000 sample = 2 * sample
true
false
• Flowchart of while loop
While loop
• Repetition structure
• Action repeated while some condition remains true
• Psuedocode
while there are more items on my shopping list
Purchase next item and cross it off my list
• while loop repeated until condition becomes false
• Example
int sample = 2;
while (sample <= 2000 )
sample = 2 * sample;
24
25
for loop
• General format when using for loops
for ( initialization; LoopCount ;increment/decrement )
• Example
for( int sample = 1; sample <= 10; sample++ )
cout << sample << endl;
• Prints int value from one to ten
 
The End
26

Más contenido relacionado

La actualidad más candente

Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithmsStudent
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading Charndeep Sekhon
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript TutorialBui Kiet
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programmingNeeru Mittal
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ LanguageWay2itech
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Md Hossen
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01Wingston
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statementsrajshreemuthiah
 
Two-dimensional array in java
Two-dimensional array in javaTwo-dimensional array in java
Two-dimensional array in javaTalha mahmood
 
Operator overloading
Operator overloadingOperator overloading
Operator overloadingBurhan Ahmed
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Adam Mukharil Bachtiar
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++bajiajugal
 

La actualidad más candente (20)

Flowcharts and algorithms
Flowcharts and algorithmsFlowcharts and algorithms
Flowcharts and algorithms
 
C++ string
C++ stringC++ string
C++ string
 
Operators in C++
Operators in C++Operators in C++
Operators in C++
 
C# Delegates
C# DelegatesC# Delegates
C# Delegates
 
Presentation on overloading
Presentation on overloading Presentation on overloading
Presentation on overloading
 
JavaScript Tutorial
JavaScript  TutorialJavaScript  Tutorial
JavaScript Tutorial
 
Introduction to programming
Introduction to programmingIntroduction to programming
Introduction to programming
 
Constructor ppt
Constructor pptConstructor ppt
Constructor ppt
 
Methods in Java
Methods in JavaMethods in Java
Methods in Java
 
Variables in C and C++ Language
Variables in C and C++ LanguageVariables in C and C++ Language
Variables in C and C++ Language
 
Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.Compiler vs Interpreter-Compiler design ppt.
Compiler vs Interpreter-Compiler design ppt.
 
Introduction to Basic C programming 01
Introduction to Basic C programming 01Introduction to Basic C programming 01
Introduction to Basic C programming 01
 
Visual basic
Visual basicVisual basic
Visual basic
 
Strings in c++
Strings in c++Strings in c++
Strings in c++
 
Control and conditional statements
Control and conditional statementsControl and conditional statements
Control and conditional statements
 
Two-dimensional array in java
Two-dimensional array in javaTwo-dimensional array in java
Two-dimensional array in java
 
Programming
ProgrammingProgramming
Programming
 
Operator overloading
Operator overloadingOperator overloading
Operator overloading
 
Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)Algorithm and Programming (Introduction of Algorithms)
Algorithm and Programming (Introduction of Algorithms)
 
Operator & Expression in c++
Operator & Expression in c++Operator & Expression in c++
Operator & Expression in c++
 

Destacado

Memory organisation ppt final presentation
Memory organisation ppt final presentationMemory organisation ppt final presentation
Memory organisation ppt final presentationrockymani
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language Mohamed Loey
 
Introduction To Ethical Hacking
Introduction To Ethical HackingIntroduction To Ethical Hacking
Introduction To Ethical HackingNeel Kamal
 
Cloud computing simple ppt
Cloud computing simple pptCloud computing simple ppt
Cloud computing simple pptAgarwaljay
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming LanguageAhmad Idrees
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computingRkrishna Mishra
 

Destacado (18)

Basic of c &c++
Basic of c &c++Basic of c &c++
Basic of c &c++
 
Memory organisation ppt final presentation
Memory organisation ppt final presentationMemory organisation ppt final presentation
Memory organisation ppt final presentation
 
Java programming course for beginners
Java programming course for beginnersJava programming course for beginners
Java programming course for beginners
 
Memory Organization
Memory OrganizationMemory Organization
Memory Organization
 
Memory organization
Memory organizationMemory organization
Memory organization
 
Java basic
Java basicJava basic
Java basic
 
C++ Programming Language
C++ Programming Language C++ Programming Language
C++ Programming Language
 
Hacking
HackingHacking
Hacking
 
ETHICAL HACKING PPT
ETHICAL HACKING PPTETHICAL HACKING PPT
ETHICAL HACKING PPT
 
Introduction To Ethical Hacking
Introduction To Ethical HackingIntroduction To Ethical Hacking
Introduction To Ethical Hacking
 
C++ ppt
C++ pptC++ ppt
C++ ppt
 
Ethical hacking presentation
Ethical hacking presentationEthical hacking presentation
Ethical hacking presentation
 
Introduction to java
Introduction to javaIntroduction to java
Introduction to java
 
Cloud computing ppt
Cloud computing pptCloud computing ppt
Cloud computing ppt
 
Cloud computing simple ppt
Cloud computing simple pptCloud computing simple ppt
Cloud computing simple ppt
 
Java tutorial PPT
Java tutorial PPTJava tutorial PPT
Java tutorial PPT
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Introduction of Cloud computing
Introduction of Cloud computingIntroduction of Cloud computing
Introduction of Cloud computing
 

Similar a Basic concept of c++

Programming fundamental 02.pptx
Programming fundamental 02.pptxProgramming fundamental 02.pptx
Programming fundamental 02.pptxZubairAli256321
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variablesTony Apreku
 
Lamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckLamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckseidounsemel
 
Cs1123 4 variables_constants
Cs1123 4 variables_constantsCs1123 4 variables_constants
Cs1123 4 variables_constantsTAlha MAlik
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing TutorialMahira Banu
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001Ralph Weber
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++Aahwini Esware gowda
 
Computer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsComputer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsJohn Paul Espino
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingRasan Samarasinghe
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Rasan Samarasinghe
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAAiman Hud
 
Lecture 01 - Introduction and Review.ppt
Lecture 01 - Introduction and Review.pptLecture 01 - Introduction and Review.ppt
Lecture 01 - Introduction and Review.pptMaiGaafar
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubeykiranrajat
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageDr.Florence Dayana
 

Similar a Basic concept of c++ (20)

Introduction to c
Introduction to cIntroduction to c
Introduction to c
 
Programming fundamental 02.pptx
Programming fundamental 02.pptxProgramming fundamental 02.pptx
Programming fundamental 02.pptx
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
Lamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ckLamborghini Veneno Allegheri #2004@f**ck
Lamborghini Veneno Allegheri #2004@f**ck
 
Cs1123 4 variables_constants
Cs1123 4 variables_constantsCs1123 4 variables_constants
Cs1123 4 variables_constants
 
C programing Tutorial
C programing TutorialC programing Tutorial
C programing Tutorial
 
C sharp part 001
C sharp part 001C sharp part 001
C sharp part 001
 
2nd PUC Computer science chapter 5 review of c++
2nd PUC Computer science chapter 5   review of c++2nd PUC Computer science chapter 5   review of c++
2nd PUC Computer science chapter 5 review of c++
 
Computer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statementsComputer programming - variables constants operators expressions and statements
Computer programming - variables constants operators expressions and statements
 
c-programming
c-programmingc-programming
c-programming
 
Esoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programmingEsoft Metro Campus - Certificate in c / c++ programming
Esoft Metro Campus - Certificate in c / c++ programming
 
Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++Esoft Metro Campus - Programming with C++
Esoft Metro Campus - Programming with C++
 
Prog1-L2.pptx
Prog1-L2.pptxProg1-L2.pptx
Prog1-L2.pptx
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
Java chapter 2
Java chapter 2Java chapter 2
Java chapter 2
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 
Lecture 01 - Introduction and Review.ppt
Lecture 01 - Introduction and Review.pptLecture 01 - Introduction and Review.ppt
Lecture 01 - Introduction and Review.ppt
 
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit DubeyMCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
MCA 101-Programming in C with Data Structure UNIT I by Prof. Rohit Dubey
 
M.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C LanguageM.Florence Dayana / Basics of C Language
M.Florence Dayana / Basics of C Language
 

Más de shashikant pabari

File System and File allocation tables
File System and File allocation tablesFile System and File allocation tables
File System and File allocation tablesshashikant pabari
 
Basic shortcut keys of computer or PC
Basic shortcut keys of computer or PCBasic shortcut keys of computer or PC
Basic shortcut keys of computer or PCshashikant pabari
 
Imap(internet massege access protocaols)
Imap(internet massege access protocaols)Imap(internet massege access protocaols)
Imap(internet massege access protocaols)shashikant pabari
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration methodshashikant pabari
 

Más de shashikant pabari (6)

Remote spy(Real Time Spy)
Remote  spy(Real Time Spy)Remote  spy(Real Time Spy)
Remote spy(Real Time Spy)
 
File System and File allocation tables
File System and File allocation tablesFile System and File allocation tables
File System and File allocation tables
 
Basic shortcut keys of computer or PC
Basic shortcut keys of computer or PCBasic shortcut keys of computer or PC
Basic shortcut keys of computer or PC
 
Imap(internet massege access protocaols)
Imap(internet massege access protocaols)Imap(internet massege access protocaols)
Imap(internet massege access protocaols)
 
Data representation
Data representationData representation
Data representation
 
Newton cotes integration method
Newton cotes integration  methodNewton cotes integration  method
Newton cotes integration method
 

Último

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSMae Pangan
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfVanessa Camilleri
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxAneriPatwari
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management SystemChristalin Nelson
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptxmary850239
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfPrerana Jadhav
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfJemuel Francisco
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesVijayaLaxmi84
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptxmary850239
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxkarenfajardo43
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxlancelewisportillo
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17Celine George
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxMichelleTuguinay1
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...Nguyen Thanh Tu Collection
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdfMr Bounab Samir
 

Último (20)

Textual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHSTextual Evidence in Reading and Writing of SHS
Textual Evidence in Reading and Writing of SHS
 
ICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdfICS2208 Lecture6 Notes for SL spaces.pdf
ICS2208 Lecture6 Notes for SL spaces.pdf
 
CHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptxCHEST Proprioceptive neuromuscular facilitation.pptx
CHEST Proprioceptive neuromuscular facilitation.pptx
 
Transaction Management in Database Management System
Transaction Management in Database Management SystemTransaction Management in Database Management System
Transaction Management in Database Management System
 
4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx4.16.24 Poverty and Precarity--Desmond.pptx
4.16.24 Poverty and Precarity--Desmond.pptx
 
Narcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdfNarcotic and Non Narcotic Analgesic..pdf
Narcotic and Non Narcotic Analgesic..pdf
 
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdfGrade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
Grade 9 Quarter 4 Dll Grade 9 Quarter 4 DLL.pdf
 
Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"Mattingly "AI & Prompt Design: Large Language Models"
Mattingly "AI & Prompt Design: Large Language Models"
 
Sulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their usesSulphonamides, mechanisms and their uses
Sulphonamides, mechanisms and their uses
 
4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx4.9.24 School Desegregation in Boston.pptx
4.9.24 School Desegregation in Boston.pptx
 
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptxGrade Three -ELLNA-REVIEWER-ENGLISH.pptx
Grade Three -ELLNA-REVIEWER-ENGLISH.pptx
 
prashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Professionprashanth updated resume 2024 for Teaching Profession
prashanth updated resume 2024 for Teaching Profession
 
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptxQ4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
Q4-PPT-Music9_Lesson-1-Romantic-Opera.pptx
 
Paradigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTAParadigm shift in nursing research by RS MEHTA
Paradigm shift in nursing research by RS MEHTA
 
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptxINCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
INCLUSIVE EDUCATION PRACTICES FOR TEACHERS AND TRAINERS.pptx
 
How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17How to Manage Buy 3 Get 1 Free in Odoo 17
How to Manage Buy 3 Get 1 Free in Odoo 17
 
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptxDIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
DIFFERENT BASKETRY IN THE PHILIPPINES PPT.pptx
 
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
31 ĐỀ THI THỬ VÀO LỚP 10 - TIẾNG ANH - FORM MỚI 2025 - 40 CÂU HỎI - BÙI VĂN V...
 
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of EngineeringFaculty Profile prashantha K EEE dept Sri Sairam college of Engineering
Faculty Profile prashantha K EEE dept Sri Sairam college of Engineering
 
MS4 level being good citizen -imperative- (1) (1).pdf
MS4 level   being good citizen -imperative- (1) (1).pdfMS4 level   being good citizen -imperative- (1) (1).pdf
MS4 level being good citizen -imperative- (1) (1).pdf
 

Basic concept of c++

  • 2. Identifiers : • They refer to the names of variables, function, array, classes etc., created by the programmer. • Each language has its own rules for naming these identifiers. • Following are common rules for both C and C++: o Only alphabetic characters, digit and underscores are permitted. o The name cannot start with a digit. o Uppercase and lowercase letters are distinct. o A declared keyword cannot be used as a variable name.
  • 3. Some Examples of Identifier Identifier Validity Reason 1digit Invalid Digit at first location is not allowed digit-1 Invalid Special characters other than underscore is not allowed num 1 Invalid Space not allowed num_1 Valid Underscore is valid identifier. 3
  • 4. Constants : • Constants refer to fixed values that do not change during the execution of a program. • They include integers, characters, floating point number and strings. • Literal constant do not have memory location. • Ex : • 123 // decimal integer • 12.34 // floating point integer • “c++” // string constant • ‘A’ // character constant 4
  • 5. Variable : • A variable is the name for a place in the computer’s memory where you store some data. • Declaration of variable : • A variable can be declared right at the place of its first use. • This make the program much easier to write and reduces the errors that may be caused by having to scan back and forth. • It also make the program easier to understand because the variables are declared in the context of their use. • Ex : float x; //declaration int a; //declaration 5
  • 6. Continue… • Reference Variable : • A new kind of variable known as the reference variable. • A reference variable provides an alternative name for a previously define variable. • For example, If we make the variable sum a reference to the variable total, then sum and total can be used interchangeable to represent that variable. • Syntax : data-type & reference-name = variable-name Ex: float total = 50; float & sum = total; 6
  • 7. Operators : • An operator is a symbol that tells the compiler to perform certain mathematical or logical operation. 1. Arithmetic Operators : o Arithmetic operators are used for mathematical calculation. o Arithmetic operators are +, -, *, /, and %. 1. Relation operators : o used to compare two numbers and taking decisions based on their relation. o Relation operators are <, <=, >, >=, ==, and != . 1. Logical operators: o Used to test more than one condition and make decisions. o Logical operators are &&, ||, and !. 7
  • 8. Continue… 4. Assignment operators : o Used to assign the result of an expression to a variable. o Assignment operators are =, +=, -=, *=, /=, and %=. 5. Increment operators : o These are special operators in c++. o Increment operators are ++, and --. 6. Conditional operators: o A ternary operator is known as conditional operators. o Ex : x = (a>b) ? a : b; which is same as if(a>b) x=a; else x=b; 8
  • 9. Continue… 7. Bitwise operator : o Used to perform operators bit by bit and may not be applied to float or double. o Bitwise operators are &, |, ^, <<, and >>. 8. Special operators : o Special operators are & is used to determine address of the variable. * is used declare a pointer variable and to get value from it. ‘ is used to link the related expression together. . is used in structure. -> is used in pointer to structure. 9
  • 10. Continue… 9. Extraction operators (>>) : o Is used with cin to input data from keyboard. 10. Insertion operators (<<) : o Is used with cout to output data from keyboard. 11. Scope resolution operators (::) o It can be used in constructing programs. We know that the same variable name can be used to have different meanings in different blocks. o Ex : int m=10; { int m=20; Output : m = 20 cout << “m” << m; ::m = 10 cout << “::m” << ::m; } 10
  • 11. Type Casting : • It is used to convert the type of a variable, function, object, expression or return value to another type. • Type casting can also done using some typecast operators available in c++. • Static_cast operator : The static_cast keyword can be used for any normal conversion between types. Conversions that rely on static (compile-time) type information. • Syntax : Static_cast <type> (object). • Const_cast operator : The const_cast keyword can be used to remove the const or volatile property from an object. • Syntax : const_cast <type> (object). 11
  • 12. Continue… • Reinterpret_cast operator : The reinterpret_cast keyword is used to simply cast one type bitwise to another. Any pointer or integral type can be cast to any other with reinterpret cast, easily allowing for misuse. • Syntax : reinterpret_cast <type> (object). • Dynamic_cast operator : The dynamic_cast keyword is used to casts a datum from one pointer or reference of a polymorphic type to another, similar to static_cast but performing a type safety check at runtime to ensure the validity of the cast. • Syntax : dynamic_cast <type> (object). 12
  • 13. Continue… • Example : Main() { double a = 21.09399; float b = 10.20; int c; c = int (a); cout << “value of int(a) is :” << c << endl; c = int (b); cout << “value of int(b) is :” << c << endl; return 0; } Output : value of int(a) is : 21 value of int(b) is : 10 13
  • 14. Enumerated Data Type : • An enumerated data type is another user-defined type which provides a way for attaching names to numbers, thereby increasing comprehensibility of the code. • The enum keyword (from c) automatically enumerates a list of words by assigning them values 0,1,2, and so on. • This facility provides an alternative means for creative symbolic comstants. • The syntax of an enum statement is similar to that of the struct statement. • Ex : enum shape {circle, square, triangle} enum colour {red, blue, green, yellow} enum position {off, on} 14
  • 15. Control Structures • A large number of function are used that pass messages, and process the data contained in objects. • A function is set to perform a task. when the task is complex, many different algorithms can be designed to achieve the same goal. Some are simple to comprehend, while others are not. • The format should be such that it is easy to trace the flow of execution of statements. • Control structure tells about the order in which the statement are executed and helps to perform manipulative, repetitive and decision making actions. • It can be used in three ways : 15
  • 16. Continue… 1) Sequence structure (straight line) 2) Selection structure (branching) 3) Loop structure (iteration or repetition) • Basic control structures 16(a) Sequence (b) Selection (c) Loop
  • 17. Continue… • Selection Structure (Branching Statements) : • if statement. • if-else statement. • switch statement. • goto statement. • Loop structure (iteration or repetition) : • While statement. • Do-while statement. • For statement.
  • 18. if Selection Structure • Selection structure • Choose among alternative courses of action • Pseudocode example: If student’s grade is greater than or equal to 60 Print “Passed” • If the condition is true • Print statement executed, program continues to next statement • If the condition is false • Print statement ignored, program continues • Indenting makes programs easier to read • C++ ignores whitespace characters (tabs, spaces, etc.)
  • 19. • Translation into C++ If student’s grade is greater than or equal to 60 Print “Passed” if ( grade >= 60 ) cout << "Passed"; • if structure • Single-entry/single-exit true false grade >= 60 print “Passed”
  • 20. if/else Selection Structure • if • Performs action if condition true • if/else • Different actions if conditions true or false • Pseudocode if student’s grade is greater than or equal to 60 print “Passed” else print “Failed” • C++ code if ( grade >= 60 ) cout << "Passed"; else cout << "Failed"; 20
  • 21. Example if ( grade >= 90 ) // 90 and above cout << "A"; else if ( grade >= 80 ) // 80-89 cout << "B"; else if ( grade >= 70 ) // 70-79 cout << "C"; else if ( grade >= 60 ) // 60-69 cout << "D"; else // less than 60 cout << "F"; 21
  • 22. Switch Case • switch • Test variable for multiple values • Series of case labels and optional default case switch ( variable ) { case value1: // taken if variable == value1 statements break; // necessary to exit switch case value2: case value3: // taken if variable == value2 or == value3 statements break; default: // taken if variable matches no other cases statements break; } 22
  • 23. While loop 23 sample <= 2000 sample = 2 * sample true false • Flowchart of while loop
  • 24. While loop • Repetition structure • Action repeated while some condition remains true • Psuedocode while there are more items on my shopping list Purchase next item and cross it off my list • while loop repeated until condition becomes false • Example int sample = 2; while (sample <= 2000 ) sample = 2 * sample; 24
  • 25. 25 for loop • General format when using for loops for ( initialization; LoopCount ;increment/decrement ) • Example for( int sample = 1; sample <= 10; sample++ ) cout << sample << endl; • Prints int value from one to ten