SlideShare a Scribd company logo
Function
Syntax of function
Declaration section
<<Returntype>> funname(parameter list);
Definition section
<<Returntype>> funname(parameter list)
{
body of the function
}
Function Call
Funname(parameter);
Example
#include<stdio.h>
void fun(int a); //declaration
int main()
{
fun(10); //Call
}
void fun(int x) //definition
{
printf(“%d”,x);
}
ACTUAL & FORMAL PARAMETERS
Actual parameters are those that are used during a
function call
Formal parameters are those that are used in function
definition and function declaration
Call by value
Calling a function with parameters passed as
values
int a=10; void fun(int a)
fun(a); {
defn;
}
Here fun(a) is a call by value.
Any modification done within the function is local to
it and will not be effected outside the function
Call By Reference
Calling a function by passing pointers as
parameters (address of variables is passed instead
of variables)
int a=1; void fun(int *x)
fun(&a); {
defn;
}
Any modification done to variable a will effect
outside the function also
Illustration
a and x are referring to same location. So value will be over written.
Illustration
Difference between call by value and
call by reference
Call by value => copying value of variable in another
variable. So any change made in the copy will not
affect the original location
Call by reference => Creating link for the parameter
to the original location. Since the address is same,
changes to the parameter will refer to original
location and the value will be over written

More Related Content

PPSX
Contoh desain presentasi interaktif dengan power point
PDF
Les algorithmes d'arithmetique
PDF
Modul pembuatan multimedia interaktif menggunakan power point
PDF
Looping in c language
PDF
CONST-- once initialised, no one can change it
DOCX
RPP BAHASA INGGRIS KELAS 7 SEMESTER 1 QUESTION TAGS
DOCX
Resensi Novel Hafalan Shalat Delisa By Widya Nugraha
PDF
Modul ajar advertisement 8 Genap.pdf
Contoh desain presentasi interaktif dengan power point
Les algorithmes d'arithmetique
Modul pembuatan multimedia interaktif menggunakan power point
Looping in c language
CONST-- once initialised, no one can change it
RPP BAHASA INGGRIS KELAS 7 SEMESTER 1 QUESTION TAGS
Resensi Novel Hafalan Shalat Delisa By Widya Nugraha
Modul ajar advertisement 8 Genap.pdf

What's hot (20)

PPTX
pengenalan microsoft power point
PPTX
Html power point
PPTX
FormationPython2019.pptx
PDF
P code
PDF
Python decorators
PDF
Python testing using mock and pytest
PPTX
5. Destructuring | ES6 | Assignment
PDF
Algorithmique programmation2018
PPT
Pragmatik
PPTX
Exception Handling in Java
PDF
Test Driven Development With Python
PDF
Python avancé : Interface graphique et programmation évènementielle
PDF
Flex bison
PDF
KUMPULAN SOAL LATIHAN UP - PPG TKI - WALID UMAR
DOCX
Hubungan semantik pragmatis
PPTX
Top down parsing
PDF
02 correction-td smi-s3-algo2
PDF
Bahan Ajar Sistem Game menggunakan Scratch
PPTX
INHERITANCE IN JAVA.pptx
PDF
Recursiviteeeeeeeeee
pengenalan microsoft power point
Html power point
FormationPython2019.pptx
P code
Python decorators
Python testing using mock and pytest
5. Destructuring | ES6 | Assignment
Algorithmique programmation2018
Pragmatik
Exception Handling in Java
Test Driven Development With Python
Python avancé : Interface graphique et programmation évènementielle
Flex bison
KUMPULAN SOAL LATIHAN UP - PPG TKI - WALID UMAR
Hubungan semantik pragmatis
Top down parsing
02 correction-td smi-s3-algo2
Bahan Ajar Sistem Game menggunakan Scratch
INHERITANCE IN JAVA.pptx
Recursiviteeeeeeeeee
Ad

Similar to User defined Functions in C (20)

PDF
Functions-Computer programming
PPTX
Presentation on function
PPT
User Defined Functions in C
ODP
Function
PDF
VIT351 Software Development VI Unit1
PDF
Programming in C Functions PPT Presentation.pdf
PPTX
Functions in C.pptx
PPTX
PPTX
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
PDF
PSPC-UNIT-4.pdf
PPTX
unit_2 (1).pptx
PPTX
Detailed concept of function in c programming
PPTX
unit_2.pptx
PPTX
Function C programming
PPTX
CH.4FUNCTIONS IN C (1).pptx
PPTX
3 Function & Storage Class.pptx
PPTX
functions in the c programming and the examples
PPTX
PDF
C_Dayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 3.pdf
PPTX
FUNCTION.pptxfkrdutytrtttrrtttttttttttttt
Functions-Computer programming
Presentation on function
User Defined Functions in C
Function
VIT351 Software Development VI Unit1
Programming in C Functions PPT Presentation.pdf
Functions in C.pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
PSPC-UNIT-4.pdf
unit_2 (1).pptx
Detailed concept of function in c programming
unit_2.pptx
Function C programming
CH.4FUNCTIONS IN C (1).pptx
3 Function & Storage Class.pptx
functions in the c programming and the examples
C_Dayyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyyy 3.pdf
FUNCTION.pptxfkrdutytrtttrrtttttttttttttt
Ad

More from Prabhu Govind (20)

PPT
Preprocessor in C
PPT
Memory allocation in c
PPT
File in c
PPT
Pointers in C
PPT
Unions in c
PPT
Structure in c
PPT
Array & string
PPT
Recursive For S-Teacher
PPT
Pre defined Functions in C
PPT
Looping in C
PPT
Branching in C
PPT
Types of operators in C
PPT
Operators in C
PPT
Statements in C
PPT
Data types in C
PPT
Constants in C
PPT
Variables_c
PPT
Tokens_C
PDF
Computer basics
PDF
Computer fundamentals
Preprocessor in C
Memory allocation in c
File in c
Pointers in C
Unions in c
Structure in c
Array & string
Recursive For S-Teacher
Pre defined Functions in C
Looping in C
Branching in C
Types of operators in C
Operators in C
Statements in C
Data types in C
Constants in C
Variables_c
Tokens_C
Computer basics
Computer fundamentals

Recently uploaded (20)

PDF
102 student loan defaulters named and shamed – Is someone you know on the list?
PPTX
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
PDF
01-Introduction-to-Information-Management.pdf
PDF
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
PDF
RMMM.pdf make it easy to upload and study
PPTX
human mycosis Human fungal infections are called human mycosis..pptx
PPTX
PPH.pptx obstetrics and gynecology in nursing
PDF
STATICS OF THE RIGID BODIES Hibbelers.pdf
PDF
Anesthesia in Laparoscopic Surgery in India
PPTX
Pharma ospi slides which help in ospi learning
PDF
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
PDF
2.FourierTransform-ShortQuestionswithAnswers.pdf
PDF
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
PPTX
Cell Types and Its function , kingdom of life
PPTX
GDM (1) (1).pptx small presentation for students
PDF
Module 4: Burden of Disease Tutorial Slides S2 2025
PDF
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
PDF
VCE English Exam - Section C Student Revision Booklet
PDF
FourierSeries-QuestionsWithAnswers(Part-A).pdf
PDF
Supply Chain Operations Speaking Notes -ICLT Program
102 student loan defaulters named and shamed – Is someone you know on the list?
1st Inaugural Professorial Lecture held on 19th February 2020 (Governance and...
01-Introduction-to-Information-Management.pdf
Black Hat USA 2025 - Micro ICS Summit - ICS/OT Threat Landscape
RMMM.pdf make it easy to upload and study
human mycosis Human fungal infections are called human mycosis..pptx
PPH.pptx obstetrics and gynecology in nursing
STATICS OF THE RIGID BODIES Hibbelers.pdf
Anesthesia in Laparoscopic Surgery in India
Pharma ospi slides which help in ospi learning
grade 11-chemistry_fetena_net_5883.pdf teacher guide for all student
2.FourierTransform-ShortQuestionswithAnswers.pdf
ANTIBIOTICS.pptx.pdf………………… xxxxxxxxxxxxx
Cell Types and Its function , kingdom of life
GDM (1) (1).pptx small presentation for students
Module 4: Burden of Disease Tutorial Slides S2 2025
BÀI TẬP BỔ TRỢ 4 KỸ NĂNG TIẾNG ANH 9 GLOBAL SUCCESS - CẢ NĂM - BÁM SÁT FORM Đ...
VCE English Exam - Section C Student Revision Booklet
FourierSeries-QuestionsWithAnswers(Part-A).pdf
Supply Chain Operations Speaking Notes -ICLT Program

User defined Functions in C

  • 1. Function Syntax of function Declaration section <<Returntype>> funname(parameter list); Definition section <<Returntype>> funname(parameter list) { body of the function } Function Call Funname(parameter);
  • 2. Example #include<stdio.h> void fun(int a); //declaration int main() { fun(10); //Call } void fun(int x) //definition { printf(“%d”,x); }
  • 3. ACTUAL & FORMAL PARAMETERS Actual parameters are those that are used during a function call Formal parameters are those that are used in function definition and function declaration
  • 4. Call by value Calling a function with parameters passed as values int a=10; void fun(int a) fun(a); { defn; } Here fun(a) is a call by value. Any modification done within the function is local to it and will not be effected outside the function
  • 5. Call By Reference Calling a function by passing pointers as parameters (address of variables is passed instead of variables) int a=1; void fun(int *x) fun(&a); { defn; } Any modification done to variable a will effect outside the function also
  • 6. Illustration a and x are referring to same location. So value will be over written.
  • 8. Difference between call by value and call by reference Call by value => copying value of variable in another variable. So any change made in the copy will not affect the original location Call by reference => Creating link for the parameter to the original location. Since the address is same, changes to the parameter will refer to original location and the value will be over written