SlideShare une entreprise Scribd logo
1  sur  10
Operators in C++

• Arithmetic Operators
• Relational Operators
• Logical Operators
• Bitwise Operators
• Assignment Operators
• Miscellaneous Operators
(greyed-out items are advanced topics and beyond the scope of this course, they have been
mentioned here as they do form part of the C++ language.)
Arithmetic Operators
Relational Operators
Logical Operators
Identifiers in C++

•

The name of a variable, function, class, or other entity in C++ is called
an identifier. C++ gives you a lot of flexibility to name identifiers as you wish.
However, there are a few rules that must be followed when naming identifiers:

•

The identifier can not be a keyword. Keywords are reserved.

•

The identifier can only be composed of letters, numbers, and the underscore
character. That means the name can not contains symbols (except the
underscore) nor whitespace.

•

The identifier must begin with a letter or an underscore. It can not start with a
number.

•

C++ distinguishes between lower and upper case letters. nvalue is different
than nValue is different than NVALUE.
Basic C++ Data Types
Typical Range
Functions in C++
•

A function is a group of statements that together perform a task. Every C++
program has at least one function, which is main(), and all the most trivial
programs can define additional functions.

•

A function declaration tells the compiler about a function's name, return type,
and parameters. A function definition provides the actual body of the function.

Defining a Function:
The general form of a C++ function definition is as follows:
return_type function_name( parameter list )
{
body of the function
}
Defining a Function cont…

•
•

•
•

•

A C++ function definition consists of a function header and a function
body. Here are all the parts of a function:
Return Type: A function may return a value. The return_type is the
data type of the value the function returns. Some functions perform
the desired operations without returning a value. In this case, the
return_type is the keyword void.
Function Name: This is the actual name of the function. The function
name and the parameter list together constitute the function
signature.
Parameters: A parameter is like a placeholder. When a function is
invoked, you pass a value to the parameter. This value is referred to
as actual parameter or argument. The parameter list refers to the
type, order, and number of the parameters of a function. Parameters
are optional; that is, a function may contain no parameters.
Function Body: The function body contains a collection of statements
that define what the function does
Defining a Function cont…

•
•

•
•

•

A C++ function definition consists of a function header and a function
body. Here are all the parts of a function:
Return Type: A function may return a value. The return_type is the
data type of the value the function returns. Some functions perform
the desired operations without returning a value. In this case, the
return_type is the keyword void.
Function Name: This is the actual name of the function. The function
name and the parameter list together constitute the function
signature.
Parameters: A parameter is like a placeholder. When a function is
invoked, you pass a value to the parameter. This value is referred to
as actual parameter or argument. The parameter list refers to the
type, order, and number of the parameters of a function. Parameters
are optional; that is, a function may contain no parameters.
Function Body: The function body contains a collection of statements
that define what the function does

Contenu connexe

Tendances

Functional programming
Functional programmingFunctional programming
Functional programming
Bas Bossink
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressions
vinay arora
 

Tendances (20)

Think in linq
Think in linqThink in linq
Think in linq
 
C ppt
C pptC ppt
C ppt
 
Insight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FPInsight into java 1.8, OOP VS FP
Insight into java 1.8, OOP VS FP
 
Operators in java
Operators in javaOperators in java
Operators in java
 
Functional programming
Functional programmingFunctional programming
Functional programming
 
C Prog. - Operators and Expressions
C Prog. - Operators and ExpressionsC Prog. - Operators and Expressions
C Prog. - Operators and Expressions
 
Report on c
Report on cReport on c
Report on c
 
Ch6
Ch6Ch6
Ch6
 
Java Tutorial Lab 4
Java Tutorial Lab 4Java Tutorial Lab 4
Java Tutorial Lab 4
 
Programming presentation
Programming presentationProgramming presentation
Programming presentation
 
Ch5a
Ch5aCh5a
Ch5a
 
Aaa ped-2- Python: Basics
Aaa ped-2- Python: BasicsAaa ped-2- Python: Basics
Aaa ped-2- Python: Basics
 
Oop using JAVA
Oop using JAVAOop using JAVA
Oop using JAVA
 
Operators in Java
Operators in JavaOperators in Java
Operators in Java
 
Operators in C Programming
Operators in C ProgrammingOperators in C Programming
Operators in C Programming
 
C++
C++ C++
C++
 
Semantics analysis
Semantics analysisSemantics analysis
Semantics analysis
 
PHP = PHunctional Programming
PHP = PHunctional ProgrammingPHP = PHunctional Programming
PHP = PHunctional Programming
 
Odersky week1 notes
Odersky week1 notesOdersky week1 notes
Odersky week1 notes
 
Operators in c programming
Operators in c programmingOperators in c programming
Operators in c programming
 

Similaire à Programming course slides c++ (Prof Mansoor Bhatti)

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

Similaire à Programming course slides c++ (Prof Mansoor Bhatti) (20)

Operator overloading C++
Operator overloading C++Operator overloading C++
Operator overloading C++
 
PSPC-UNIT-4.pdf
PSPC-UNIT-4.pdfPSPC-UNIT-4.pdf
PSPC-UNIT-4.pdf
 
Functions.pptx
Functions.pptxFunctions.pptx
Functions.pptx
 
Operator overloading (binary)
Operator overloading (binary)Operator overloading (binary)
Operator overloading (binary)
 
Python Basics.pptx
Python Basics.pptxPython Basics.pptx
Python Basics.pptx
 
C_plus_plus
C_plus_plusC_plus_plus
C_plus_plus
 
An Introduction on Functions in python 3.pdf
An Introduction on Functions in python 3.pdfAn Introduction on Functions in python 3.pdf
An Introduction on Functions in python 3.pdf
 
C Language Part 1
C Language Part 1C Language Part 1
C Language Part 1
 
Chapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B KuteChapter 01 Introduction to Java by Tushar B Kute
Chapter 01 Introduction to Java by Tushar B Kute
 
Basics of c++ Programming Language
Basics of c++ Programming LanguageBasics of c++ Programming Language
Basics of c++ Programming Language
 
Lecture 2 variables
Lecture 2 variablesLecture 2 variables
Lecture 2 variables
 
Functions in C.pptx
Functions in C.pptxFunctions in C.pptx
Functions in C.pptx
 
C programming tutorial for Beginner
C programming tutorial for BeginnerC programming tutorial for Beginner
C programming tutorial for Beginner
 
C++.pptx
C++.pptxC++.pptx
C++.pptx
 
Functions in C++
Functions in C++Functions in C++
Functions in C++
 
unit1 python.pptx
unit1 python.pptxunit1 python.pptx
unit1 python.pptx
 
Intro To C++ - Class #19: Functions
Intro To C++ - Class #19: FunctionsIntro To C++ - Class #19: Functions
Intro To C++ - Class #19: Functions
 
Chapter 6 - Modular Programming- in C++.pptx
Chapter 6 - Modular Programming- in C++.pptxChapter 6 - Modular Programming- in C++.pptx
Chapter 6 - Modular Programming- in C++.pptx
 
Functions and modular programming.pptx
Functions and modular programming.pptxFunctions and modular programming.pptx
Functions and modular programming.pptx
 
POLITEKNIK MALAYSIA
POLITEKNIK MALAYSIAPOLITEKNIK MALAYSIA
POLITEKNIK MALAYSIA
 

Plus de Syed Arslan Rizvi (13)

Fbr regulations of taxing structure for hospital sector
Fbr regulations of taxing structure for hospital sectorFbr regulations of taxing structure for hospital sector
Fbr regulations of taxing structure for hospital sector
 
tax amnesty
tax amnestytax amnesty
tax amnesty
 
shop ad template
shop ad templateshop ad template
shop ad template
 
Tax amnesty
Tax amnestyTax amnesty
Tax amnesty
 
Intro ch 05_a
Intro ch 05_aIntro ch 05_a
Intro ch 05_a
 
how digital camera works or mechanism of Digital camera
how digital camera works or mechanism of Digital camera how digital camera works or mechanism of Digital camera
how digital camera works or mechanism of Digital camera
 
how to write a good cv by syed arslan rizvi
how to write a good cv by syed arslan rizvihow to write a good cv by syed arslan rizvi
how to write a good cv by syed arslan rizvi
 
DDworkers syedarslanrizvi
DDworkers syedarslanrizviDDworkers syedarslanrizvi
DDworkers syedarslanrizvi
 
muree tour our
muree tour ourmuree tour our
muree tour our
 
how just moon split syed arslan rizvi
how just moon split syed arslan rizvihow just moon split syed arslan rizvi
how just moon split syed arslan rizvi
 
Programming topics. syed arslan rizvi
Programming topics. syed arslan rizviProgramming topics. syed arslan rizvi
Programming topics. syed arslan rizvi
 
information processing by peter nothon chapter 1A
information processing by peter nothon chapter 1Ainformation processing by peter nothon chapter 1A
information processing by peter nothon chapter 1A
 
information processing by peter nothon chapter 1B
information processing by peter nothon chapter 1Binformation processing by peter nothon chapter 1B
information processing by peter nothon chapter 1B
 

Dernier

1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
QucHHunhnh
 
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
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
QucHHunhnh
 

Dernier (20)

Holdier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdfHoldier Curriculum Vitae (April 2024).pdf
Holdier Curriculum Vitae (April 2024).pdf
 
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
 
Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...Making communications land - Are they received and understood as intended? we...
Making communications land - Are they received and understood as intended? we...
 
Unit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptxUnit-IV; Professional Sales Representative (PSR).pptx
Unit-IV; Professional Sales Representative (PSR).pptx
 
Sociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning ExhibitSociology 101 Demonstration of Learning Exhibit
Sociology 101 Demonstration of Learning Exhibit
 
1029-Danh muc Sach Giao Khoa khoi 6.pdf
1029-Danh muc Sach Giao Khoa khoi  6.pdf1029-Danh muc Sach Giao Khoa khoi  6.pdf
1029-Danh muc Sach Giao Khoa khoi 6.pdf
 
This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.This PowerPoint helps students to consider the concept of infinity.
This PowerPoint helps students to consider the concept of infinity.
 
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
 
On National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan FellowsOn National Teacher Day, meet the 2024-25 Kenan Fellows
On National Teacher Day, meet the 2024-25 Kenan Fellows
 
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
Explore beautiful and ugly buildings. Mathematics helps us create beautiful d...
 
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
2024-NATIONAL-LEARNING-CAMP-AND-OTHER.pptx
 
ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701ComPTIA Overview | Comptia Security+ Book SY0-701
ComPTIA Overview | Comptia Security+ Book SY0-701
 
Understanding Accommodations and Modifications
Understanding  Accommodations and ModificationsUnderstanding  Accommodations and Modifications
Understanding Accommodations and Modifications
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
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...
 
Unit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptxUnit-IV- Pharma. Marketing Channels.pptx
Unit-IV- Pharma. Marketing Channels.pptx
 
psychiatric nursing HISTORY COLLECTION .docx
psychiatric  nursing HISTORY  COLLECTION  .docxpsychiatric  nursing HISTORY  COLLECTION  .docx
psychiatric nursing HISTORY COLLECTION .docx
 
1029 - Danh muc Sach Giao Khoa 10 . pdf
1029 -  Danh muc Sach Giao Khoa 10 . pdf1029 -  Danh muc Sach Giao Khoa 10 . pdf
1029 - Danh muc Sach Giao Khoa 10 . pdf
 
Spatium Project Simulation student brief
Spatium Project Simulation student briefSpatium Project Simulation student brief
Spatium Project Simulation student brief
 
Magic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptxMagic bus Group work1and 2 (Team 3).pptx
Magic bus Group work1and 2 (Team 3).pptx
 

Programming course slides c++ (Prof Mansoor Bhatti)

  • 1. Operators in C++ • Arithmetic Operators • Relational Operators • Logical Operators • Bitwise Operators • Assignment Operators • Miscellaneous Operators (greyed-out items are advanced topics and beyond the scope of this course, they have been mentioned here as they do form part of the C++ language.)
  • 5. Identifiers in C++ • The name of a variable, function, class, or other entity in C++ is called an identifier. C++ gives you a lot of flexibility to name identifiers as you wish. However, there are a few rules that must be followed when naming identifiers: • The identifier can not be a keyword. Keywords are reserved. • The identifier can only be composed of letters, numbers, and the underscore character. That means the name can not contains symbols (except the underscore) nor whitespace. • The identifier must begin with a letter or an underscore. It can not start with a number. • C++ distinguishes between lower and upper case letters. nvalue is different than nValue is different than NVALUE.
  • 8. Functions in C++ • A function is a group of statements that together perform a task. Every C++ program has at least one function, which is main(), and all the most trivial programs can define additional functions. • A function declaration tells the compiler about a function's name, return type, and parameters. A function definition provides the actual body of the function. Defining a Function: The general form of a C++ function definition is as follows: return_type function_name( parameter list ) { body of the function }
  • 9. Defining a Function cont… • • • • • A C++ function definition consists of a function header and a function body. Here are all the parts of a function: Return Type: A function may return a value. The return_type is the data type of the value the function returns. Some functions perform the desired operations without returning a value. In this case, the return_type is the keyword void. Function Name: This is the actual name of the function. The function name and the parameter list together constitute the function signature. Parameters: A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a function. Parameters are optional; that is, a function may contain no parameters. Function Body: The function body contains a collection of statements that define what the function does
  • 10. Defining a Function cont… • • • • • A C++ function definition consists of a function header and a function body. Here are all the parts of a function: Return Type: A function may return a value. The return_type is the data type of the value the function returns. Some functions perform the desired operations without returning a value. In this case, the return_type is the keyword void. Function Name: This is the actual name of the function. The function name and the parameter list together constitute the function signature. Parameters: A parameter is like a placeholder. When a function is invoked, you pass a value to the parameter. This value is referred to as actual parameter or argument. The parameter list refers to the type, order, and number of the parameters of a function. Parameters are optional; that is, a function may contain no parameters. Function Body: The function body contains a collection of statements that define what the function does