SlideShare a Scribd company logo
{
Functions
Abdullah Hassan Al ElianiName :
Academic Number : 214363617
Supervision : Ibrahim Al Odieni
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.
Introduction
{
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.
{
Function declaration, is done to tell the
compiler about the existence of the
function. Function's return type, its name &
parameter list is mentioned.
Function body is written in its definition
look at the example up.
{
Example:
#include < iostream>
using namespace std;
int sum (int x, int y); //declaring function
int main()
{
int a = 10;
int b = 20;
int c = sum (a, b); //calling function
cout << c;
}
int sum (int x, int y) //defining function
{
return (X + y);
}
{
Here, initially the function is declared,
without body. Then inside main() function it
is called, as the function returns sumation of
two values, hence z is their to store the value of
sum. Then, at last, function is defined, where
the body of function is mentioned. We can also,
declare & define the function together, but then it
should be done before it is called.
 http://www.studytonight.com/cpp/functions-
in-cpp
 https://www.tutorialspoint.com/cplusplus/cpp_
functions.htm
 http://www.cplusplus.com/doc/tutorial/functio
ns/
refrences

More Related Content

PPTX
parameter passing in c#
PPTX
Call by value
PPTX
Functions in c
ODP
Function
PPT
Function in C Language
PPTX
Function overloading
PPT
Function overloading(C++)
PPTX
Presentation on function
parameter passing in c#
Call by value
Functions in c
Function
Function in C Language
Function overloading
Function overloading(C++)
Presentation on function

What's hot (20)

PPTX
Functions in c language
PPTX
Function in c
PPTX
Operator overloading
PPTX
Working with functions in matlab
PPTX
Classes function overloading
PPTX
PPTX
Types of function call
PPTX
Function in c program
DOCX
18 dec pointers and scope resolution operator
PPTX
Parameter passing to_functions_in_c
PPT
Functions in C++
PPT
16717 functions in C++
 
PPTX
Function Pointer in C
PPTX
Operator overloading
PPTX
functions in C
PPTX
Functions in C
PPT
Operator overloading
PPTX
PARAMETER PASSING MECHANISMS
PPTX
Method parameters in c#
PPTX
Functions in c language
Function in c
Operator overloading
Working with functions in matlab
Classes function overloading
Types of function call
Function in c program
18 dec pointers and scope resolution operator
Parameter passing to_functions_in_c
Functions in C++
16717 functions in C++
 
Function Pointer in C
Operator overloading
functions in C
Functions in C
Operator overloading
PARAMETER PASSING MECHANISMS
Method parameters in c#
Ad

Viewers also liked (15)

PDF
Deber de informatica 10
PPT
trabajo con diapositivas
DOCX
Resumo Professor Mateus Frozza - Conhecimentos Bancários
PDF
Practica 1
PDF
Up from Slavery
DOC
51351085 Ganesh subramanian profile
PDF
MGMA Health Care Case Competition 2016
PDF
Education in a hip hop nation- our identity politics &amp; pedagogy
PPTX
El sistema de gestión de la calidad
PPTX
Pnaic geometria 3_formacao_2016
PPT
Capitulo 6 a oração do senhor
PPT
SISTEMA DE ESCRITA ALFABÉTICA - SEA
PPTX
Behavior based safety software
PDF
ChengDu University Invited Conference
PDF
JC Act Summaries
Deber de informatica 10
trabajo con diapositivas
Resumo Professor Mateus Frozza - Conhecimentos Bancários
Practica 1
Up from Slavery
51351085 Ganesh subramanian profile
MGMA Health Care Case Competition 2016
Education in a hip hop nation- our identity politics &amp; pedagogy
El sistema de gestión de la calidad
Pnaic geometria 3_formacao_2016
Capitulo 6 a oração do senhor
SISTEMA DE ESCRITA ALFABÉTICA - SEA
Behavior based safety software
ChengDu University Invited Conference
JC Act Summaries
Ad

Similar to Functions (20)

DOC
Functions
PPTX
Module 3-Functions
PDF
FUNCTIONS IN C PROGRAMMING.pdf
PDF
Cpp functions
PDF
unit3 part2 pcds function notes.pdf
PPTX
User defined function in C.pptx
PPTX
Detailed concept of function in c programming
PPTX
Abdullah alotaibi functions
PDF
functionsinc-130108032745-phpapp01.pdf
PPTX
Functions1
PPTX
Amit user defined functions xi (2)
PPT
Lecture 11 - Functions
PPTX
Functions in C.pptx
PPTX
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
PPTX
Functions in c++,
PPT
Ch4 functions
PDF
All chapters C++ - Copy.pdfyttttttttttttttttttttttttttttt
PPTX
Lecture_5_-_Functions_in_C_Detailed.pptx
PPTX
Dti2143 chapter 5
PDF
Functions
Module 3-Functions
FUNCTIONS IN C PROGRAMMING.pdf
Cpp functions
unit3 part2 pcds function notes.pdf
User defined function in C.pptx
Detailed concept of function in c programming
Abdullah alotaibi functions
functionsinc-130108032745-phpapp01.pdf
Functions1
Amit user defined functions xi (2)
Lecture 11 - Functions
Functions in C.pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Functions in c++,
Ch4 functions
All chapters C++ - Copy.pdfyttttttttttttttttttttttttttttt
Lecture_5_-_Functions_in_C_Detailed.pptx
Dti2143 chapter 5

Recently uploaded (20)

PPTX
Lesson notes of climatology university.
PDF
advance database management system book.pdf
PDF
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
PDF
Paper A Mock Exam 9_ Attempt review.pdf.
PPTX
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
PDF
Complications of Minimal Access Surgery at WLH
PDF
Trump Administration's workforce development strategy
PPTX
Digestion and Absorption of Carbohydrates, Proteina and Fats
PDF
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
PPTX
Final Presentation General Medicine 03-08-2024.pptx
PDF
Supply Chain Operations Speaking Notes -ICLT Program
PPTX
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
PDF
Classroom Observation Tools for Teachers
PPTX
202450812 BayCHI UCSC-SV 20250812 v17.pptx
PPTX
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
PDF
What if we spent less time fighting change, and more time building what’s rig...
PDF
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
PPTX
Cell Types and Its function , kingdom of life
PPTX
Unit 4 Skeletal System.ppt.pptxopresentatiom
PDF
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE
Lesson notes of climatology university.
advance database management system book.pdf
GENETICS IN BIOLOGY IN SECONDARY LEVEL FORM 3
Paper A Mock Exam 9_ Attempt review.pdf.
CHAPTER IV. MAN AND BIOSPHERE AND ITS TOTALITY.pptx
Complications of Minimal Access Surgery at WLH
Trump Administration's workforce development strategy
Digestion and Absorption of Carbohydrates, Proteina and Fats
RTP_AR_KS1_Tutor's Guide_English [FOR REPRODUCTION].pdf
Final Presentation General Medicine 03-08-2024.pptx
Supply Chain Operations Speaking Notes -ICLT Program
Radiologic_Anatomy_of_the_Brachial_plexus [final].pptx
Classroom Observation Tools for Teachers
202450812 BayCHI UCSC-SV 20250812 v17.pptx
UV-Visible spectroscopy..pptx UV-Visible Spectroscopy – Electronic Transition...
What if we spent less time fighting change, and more time building what’s rig...
OBE - B.A.(HON'S) IN INTERIOR ARCHITECTURE -Ar.MOHIUDDIN.pdf
Cell Types and Its function , kingdom of life
Unit 4 Skeletal System.ppt.pptxopresentatiom
LNK 2025 (2).pdf MWEHEHEHEHEHEHEHEHEHEHE

Functions

  • 1. { Functions Abdullah Hassan Al ElianiName : Academic Number : 214363617 Supervision : Ibrahim Al Odieni
  • 2. 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. Introduction
  • 3. { 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.
  • 4. { Function declaration, is done to tell the compiler about the existence of the function. Function's return type, its name & parameter list is mentioned. Function body is written in its definition look at the example up.
  • 5. { Example: #include < iostream> using namespace std; int sum (int x, int y); //declaring function int main() { int a = 10; int b = 20; int c = sum (a, b); //calling function cout << c; } int sum (int x, int y) //defining function { return (X + y); }
  • 6. { Here, initially the function is declared, without body. Then inside main() function it is called, as the function returns sumation of two values, hence z is their to store the value of sum. Then, at last, function is defined, where the body of function is mentioned. We can also, declare & define the function together, but then it should be done before it is called.