SlideShare a Scribd company logo
1 of 10
Presentation on
“Function in C”
Prepared By
Sabbir Ahmed Sayeem
ID : 01020109008
Semester : 3rd
Department of EEE
Pundra University of Science and Technology
Contents :
• Why Function?
• Introduction.
• Predefined Function.
• User Defined Function.
• Function Declaration.
• An Example to understand
Function in C.
• Five key Points to Note regarding
functions in C!!
Why Function?
Functions are used because of following
reasons –
a) To improve the readability of code.
b) Improves the reusability of the code,
same function can be used in any program
rather than writing the same code from
scratch.
c) Debugging of the code would be easier if
you use functions, as errors are easy to be
traced.
d) Reduces the size of the code, duplicate
set of statements are replaced by function
calls.
Predefined Function
Standard library functions are also
known as built-in functions. Functions
such
as puts(), gets(), printf(),
scanf() etc are standard library
functions. These functions are already
defined in header files (files with .h
extensions are called header files such
as stdio.h), so we just call them
whenever there is a need to use them.
For example, printf() function is
defined in <stdio.h> header file so in
order to use the printf() function, we
need to include the <stdio.h> header file
in our program using #include
<stdio.h>.
User Defined functions
The functions that we create in a program
are known as user defined functions or in
other words we can say that a function
created by user is known as user defined
function.
Function Declaration
The function declaration statement informs the compiler about a function
return type, function name and parameters or arguments type.
Syntax : return-type function-name (arguments);
Return type : return type is the data type of the value which is given back
to the calling function.
function name : function name is the name of a function. A function is
called by using the function name. The naming rules are same as variable
naming.
parameters or arguments type : C allows programmers to pass
information to the called function from the calling function by using
parameters. These parameters are variables of data type.
C program - Functions
The following example program will clearly explain the concept of functions
The above C program illustrates that a function
declaration, function definition and function call in a
program.
Five key Points to Note
regarding functions in C:
1) main() in C program is also a function.
2) Each C program must have at least one function,
which is main().
3) There is no limit on number of functions; C program
can have any number of functions.
4) A function can call itself and it is known as
“Recursion“.
and
5) C Functions Terminologies that we must
remember
return type: Data type of returned value. It can be void
also, in such case function doesn’t return any value.
Function in c programming

More Related Content

What's hot

What's hot (19)

Header files in c
Header files in cHeader files in c
Header files in c
 
Functions
FunctionsFunctions
Functions
 
Recursive Function
Recursive FunctionRecursive Function
Recursive Function
 
Programming in c++ ppt
Programming in c++ pptProgramming in c++ ppt
Programming in c++ ppt
 
Function C programming
Function C programmingFunction C programming
Function C programming
 
Structure of a C program
Structure of a C programStructure of a C program
Structure of a C program
 
structure of a c program
structure of a c programstructure of a c program
structure of a c program
 
Function
FunctionFunction
Function
 
Programming Fundamentals Functions in C and types
Programming Fundamentals  Functions in C  and typesProgramming Fundamentals  Functions in C  and types
Programming Fundamentals Functions in C and types
 
Function
FunctionFunction
Function
 
Introduction to C programming
Introduction to C programmingIntroduction to C programming
Introduction to C programming
 
Functions in c language
Functions in c language Functions in c language
Functions in c language
 
Functions in c
Functions in cFunctions in c
Functions in c
 
Basic information of function in cpu
Basic information of function in cpuBasic information of function in cpu
Basic information of function in cpu
 
Built in function
Built in functionBuilt in function
Built in function
 
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM) FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
FUNCTION IN C PROGRAMMING UNIT -6 (BCA I SEM)
 
Function in C and C++
Function in C and C++Function in C and C++
Function in C and C++
 
Basic structure of c programming
Basic structure of c programmingBasic structure of c programming
Basic structure of c programming
 
User defined functions.1
User defined functions.1User defined functions.1
User defined functions.1
 

Similar to Function in c programming

Similar to Function in c programming (20)

Functions in c language
Functions in c languageFunctions in c language
Functions in c language
 
U19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).pptU19CS101 - PPS Unit 4 PPT (1).ppt
U19CS101 - PPS Unit 4 PPT (1).ppt
 
Programming in c++ ppt
Programming in c++ pptProgramming in c++ ppt
Programming in c++ ppt
 
arrays.ppt
arrays.pptarrays.ppt
arrays.ppt
 
Presentation 2.pptx
Presentation 2.pptxPresentation 2.pptx
Presentation 2.pptx
 
Functions
Functions Functions
Functions
 
1.6 Function.pdf
1.6 Function.pdf1.6 Function.pdf
1.6 Function.pdf
 
VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1VIT351 Software Development VI Unit1
VIT351 Software Development VI Unit1
 
Ch4 functions
Ch4 functionsCh4 functions
Ch4 functions
 
5. Functions in C.pdf
5. Functions in C.pdf5. Functions in C.pdf
5. Functions in C.pdf
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
Function in c
Function in cFunction in c
Function in c
 
unit_2 (1).pptx
unit_2 (1).pptxunit_2 (1).pptx
unit_2 (1).pptx
 
Chapter One Function.pptx
Chapter One Function.pptxChapter One Function.pptx
Chapter One Function.pptx
 
DS functions-1.pptx
DS functions-1.pptxDS functions-1.pptx
DS functions-1.pptx
 
Unit-III.pptx
Unit-III.pptxUnit-III.pptx
Unit-III.pptx
 
FUNCTION CPU
FUNCTION CPUFUNCTION CPU
FUNCTION CPU
 
Modular Programming in C
Modular Programming in CModular Programming in C
Modular Programming in C
 
Functions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothiFunctions in c mrs.sowmya jyothi
Functions in c mrs.sowmya jyothi
 
c.p function
c.p functionc.p function
c.p function
 

Recently uploaded

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...christianmathematics
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfciinovamais
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfsanyamsingh5019
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingTechSoup
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Celine George
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introductionMaksud Ahmed
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxheathfieldcps1
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpinRaunakKeshri1
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAssociation for Project Management
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationnomboosow
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room servicediscovermytutordmt
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfAyushMahapatra5
 
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 . pdfQucHHunhnh
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104misteraugie
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajanpragatimahajan3
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024Janet Corral
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...Sapna Thakur
 

Recently uploaded (20)

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...
 
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
Mattingly "AI & Prompt Design: Structured Data, Assistants, & RAG"
 
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptxINDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
INDIA QUIZ 2024 RLAC DELHI UNIVERSITY.pptx
 
Activity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdfActivity 01 - Artificial Culture (1).pdf
Activity 01 - Artificial Culture (1).pdf
 
Sanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdfSanyam Choudhary Chemistry practical.pdf
Sanyam Choudhary Chemistry practical.pdf
 
Grant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy ConsultingGrant Readiness 101 TechSoup and Remy Consulting
Grant Readiness 101 TechSoup and Remy Consulting
 
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"Mattingly "AI & Prompt Design: The Basics of Prompt Design"
Mattingly "AI & Prompt Design: The Basics of Prompt Design"
 
Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17Advanced Views - Calendar View in Odoo 17
Advanced Views - Calendar View in Odoo 17
 
microwave assisted reaction. General introduction
microwave assisted reaction. General introductionmicrowave assisted reaction. General introduction
microwave assisted reaction. General introduction
 
The basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptxThe basics of sentences session 2pptx copy.pptx
The basics of sentences session 2pptx copy.pptx
 
Student login on Anyboli platform.helpin
Student login on Anyboli platform.helpinStudent login on Anyboli platform.helpin
Student login on Anyboli platform.helpin
 
APM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across SectorsAPM Welcome, APM North West Network Conference, Synergies Across Sectors
APM Welcome, APM North West Network Conference, Synergies Across Sectors
 
Interactive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communicationInteractive Powerpoint_How to Master effective communication
Interactive Powerpoint_How to Master effective communication
 
9548086042 for call girls in Indira Nagar with room service
9548086042  for call girls in Indira Nagar  with room service9548086042  for call girls in Indira Nagar  with room service
9548086042 for call girls in Indira Nagar with room service
 
Class 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdfClass 11th Physics NEET formula sheet pdf
Class 11th Physics NEET formula sheet pdf
 
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
 
Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104Nutritional Needs Presentation - HLTH 104
Nutritional Needs Presentation - HLTH 104
 
social pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajansocial pharmacy d-pharm 1st year by Pragati K. Mahajan
social pharmacy d-pharm 1st year by Pragati K. Mahajan
 
General AI for Medical Educators April 2024
General AI for Medical Educators April 2024General AI for Medical Educators April 2024
General AI for Medical Educators April 2024
 
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
BAG TECHNIQUE Bag technique-a tool making use of public health bag through wh...
 

Function in c programming

  • 1. Presentation on “Function in C” Prepared By Sabbir Ahmed Sayeem ID : 01020109008 Semester : 3rd Department of EEE Pundra University of Science and Technology
  • 2. Contents : • Why Function? • Introduction. • Predefined Function. • User Defined Function. • Function Declaration. • An Example to understand Function in C. • Five key Points to Note regarding functions in C!!
  • 3. Why Function? Functions are used because of following reasons – a) To improve the readability of code. b) Improves the reusability of the code, same function can be used in any program rather than writing the same code from scratch. c) Debugging of the code would be easier if you use functions, as errors are easy to be traced. d) Reduces the size of the code, duplicate set of statements are replaced by function calls.
  • 4.
  • 5. Predefined Function Standard library functions are also known as built-in functions. Functions such as puts(), gets(), printf(), scanf() etc are standard library functions. These functions are already defined in header files (files with .h extensions are called header files such as stdio.h), so we just call them whenever there is a need to use them. For example, printf() function is defined in <stdio.h> header file so in order to use the printf() function, we need to include the <stdio.h> header file in our program using #include <stdio.h>.
  • 6. User Defined functions The functions that we create in a program are known as user defined functions or in other words we can say that a function created by user is known as user defined function.
  • 7. Function Declaration The function declaration statement informs the compiler about a function return type, function name and parameters or arguments type. Syntax : return-type function-name (arguments); Return type : return type is the data type of the value which is given back to the calling function. function name : function name is the name of a function. A function is called by using the function name. The naming rules are same as variable naming. parameters or arguments type : C allows programmers to pass information to the called function from the calling function by using parameters. These parameters are variables of data type.
  • 8. C program - Functions The following example program will clearly explain the concept of functions The above C program illustrates that a function declaration, function definition and function call in a program.
  • 9. Five key Points to Note regarding functions in C: 1) main() in C program is also a function. 2) Each C program must have at least one function, which is main(). 3) There is no limit on number of functions; C program can have any number of functions. 4) A function can call itself and it is known as “Recursion“. and 5) C Functions Terminologies that we must remember return type: Data type of returned value. It can be void also, in such case function doesn’t return any value.