SlideShare a Scribd company logo
1 of 9
CALL BY VALUE
&
CALL BY REFERNCE
TOPIC:
PRESENTED BY
DHARANI
THERE ARE TWO WAYS IN WHICH WE CAN
PASS ARGUMENTS TO THE FUNCTION
CALL BY VALUE
 Value of actual arguments passed to the
formal arguments.
Any change made in the formal arguments
does not effect the actual arguments.
When function is called it does not affect the
actual contents of the actual arguments.
#include <stdio.h>
void call_by_value(int x)
{
printf("Inside call_by_value x = %d before adding 10.n", x);
x += 10;
printf("Inside call_by_value x = %d after adding 10.n", x);
}
int main() {
int a=10;
printf("a = %d before function call_by_value.n", a);
call_by_value(a);
printf("a = %d after function call_by_value.n", a);
return 0;
}
EXAMPLE PROGRAM
OUTPUT OF THE PROGRAM
a = 10 before function call_by_value.
Inside call_by_value x = 10 before
adding 10.
Inside call_by_value x = 20 after
adding 10.
a = 10 after function call_by_value.
Actual and Formal arguments
 Arguments passed to the function during function call
are known as actual arguments
 The arguments we use during a function definition are
known as formal arguments.
For a function call to be valid the type, order and number of
actual and formal arguments must always be same.
 Value of each of the actual arguments in the calling function
is copied into the formal arguments of the called function.
Changes made have no effect on the values of actual
arguments in the calling function.
Concept of Actual and Formal
arguments
CALL BY VALUE CALL BY REFERENCE
CALLING FUNCTION SENDS COPIES TO
DATA.
THE FORMAL PARAMETERS ARE
ORDINARY VARIABLES.
ATMOST ONLY ONE VALUES CAN BE SENT
BACK TO THE CALLING FUNCTION.
ACTUAL PARAMETERS ARE AFFECTED BY
CHANGES MADE WITHIN THE FUNCTION.
CALLING FUNCTION SENDS ADDRESS OF
DATA.
THE FORMAL PARAMETERS ARE POINTER
VARIABLE.
SEVERAL RESULTS CAN BE SENT BACK
TO THE CALLING FUNCTION.
DIRECT CHANGES ARE MADE TO THE
ACTUAL PARAMETERS.
Call by value

More Related Content

What's hot

Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
hassaanciit
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
alish sha
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
Mainak Sasmal
 

What's hot (20)

C programming array & shorting
C  programming array & shortingC  programming array & shorting
C programming array & shorting
 
function in c
function in cfunction in c
function in c
 
Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04Introduction to Computer and Programing - Lecture 04
Introduction to Computer and Programing - Lecture 04
 
Dti2143 lab sheet 6
Dti2143 lab sheet 6Dti2143 lab sheet 6
Dti2143 lab sheet 6
 
Expressions using operator in c
Expressions using operator in cExpressions using operator in c
Expressions using operator in c
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
Implement a queue using two stacks.
Implement a queue using two stacks.Implement a queue using two stacks.
Implement a queue using two stacks.
 
C program to add n numbers
C program to add n numbers C program to add n numbers
C program to add n numbers
 
Practical write a c program to reverse a given number
Practical write a c program to reverse a given numberPractical write a c program to reverse a given number
Practical write a c program to reverse a given number
 
C Programming Language Part 7
C Programming Language Part 7C Programming Language Part 7
C Programming Language Part 7
 
Core programming in c
Core programming in cCore programming in c
Core programming in c
 
Program presentation
Program presentationProgram presentation
Program presentation
 
88 c-programs
88 c-programs88 c-programs
88 c-programs
 
Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3Bcsl 033 data and file structures lab s5-3
Bcsl 033 data and file structures lab s5-3
 
Data Structure using C
Data Structure using CData Structure using C
Data Structure using C
 
Program in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointersProgram in ‘C’ language to implement linear search using pointers
Program in ‘C’ language to implement linear search using pointers
 
C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2C Programming Language Step by Step Part 2
C Programming Language Step by Step Part 2
 
C Programming Language Part 9
C Programming Language Part 9C Programming Language Part 9
C Programming Language Part 9
 
C programming Lab 1
C programming Lab 1C programming Lab 1
C programming Lab 1
 
Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2Bcsl 033 data and file structures lab s5-2
Bcsl 033 data and file structures lab s5-2
 

Viewers also liked

Wigle Whiskey
Wigle WhiskeyWigle Whiskey
Wigle Whiskey
gmlohr
 
インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発
インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発
インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発
Satoru Yamaguchi
 
Genevieve lohr u.s. stats 2010 2013
Genevieve lohr u.s. stats 2010 2013Genevieve lohr u.s. stats 2010 2013
Genevieve lohr u.s. stats 2010 2013
gmlohr
 
モバイル対応Ui部品を利用したレスポンシブwebアプリ開発
モバイル対応Ui部品を利用したレスポンシブwebアプリ開発モバイル対応Ui部品を利用したレスポンシブwebアプリ開発
モバイル対応Ui部品を利用したレスポンシブwebアプリ開発
Satoru Yamaguchi
 

Viewers also liked (16)

Budgeting
BudgetingBudgeting
Budgeting
 
Tabel periodik chemist 2
Tabel periodik chemist 2Tabel periodik chemist 2
Tabel periodik chemist 2
 
Wigle Whiskey
Wigle WhiskeyWigle Whiskey
Wigle Whiskey
 
高速プロトタイピングで失敗しないUI開発 - Developer summit 2016 summer
高速プロトタイピングで失敗しないUI開発 - Developer summit 2016 summer高速プロトタイピングで失敗しないUI開発 - Developer summit 2016 summer
高速プロトタイピングで失敗しないUI開発 - Developer summit 2016 summer
 
データ視覚化・分析アプリケーションの超速開発
データ視覚化・分析アプリケーションの超速開発データ視覚化・分析アプリケーションの超速開発
データ視覚化・分析アプリケーションの超速開発
 
Tarea de tic 4
Tarea de tic 4Tarea de tic 4
Tarea de tic 4
 
Fisiologia del dolor
Fisiologia del dolorFisiologia del dolor
Fisiologia del dolor
 
インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発
インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発
インフラジスティックス Wpf コントロールを用いたリッチ アプリケーション開発
 
Tugas limbah
Tugas limbahTugas limbah
Tugas limbah
 
Genevieve lohr u.s. stats 2010 2013
Genevieve lohr u.s. stats 2010 2013Genevieve lohr u.s. stats 2010 2013
Genevieve lohr u.s. stats 2010 2013
 
scan0001
scan0001scan0001
scan0001
 
Histologia Sistema Motor
Histologia Sistema MotorHistologia Sistema Motor
Histologia Sistema Motor
 
モバイル対応Ui部品を利用したレスポンシブwebアプリ開発
モバイル対応Ui部品を利用したレスポンシブwebアプリ開発モバイル対応Ui部品を利用したレスポンシブwebアプリ開発
モバイル対応Ui部品を利用したレスポンシブwebアプリ開発
 
Histologia de oido-gusto-olfato
Histologia de oido-gusto-olfatoHistologia de oido-gusto-olfato
Histologia de oido-gusto-olfato
 
Sistema nervioso autónomo
Sistema nervioso autónomoSistema nervioso autónomo
Sistema nervioso autónomo
 
Fisiologia Sistema Motor
Fisiologia Sistema MotorFisiologia Sistema Motor
Fisiologia Sistema Motor
 

Similar to Call by value

Call by value
Call by valueCall by value
Call by value
Dharani G
 

Similar to Call by value (20)

Call by value
Call by valueCall by value
Call by value
 
Function in c
Function in cFunction in c
Function in c
 
Function in c
Function in cFunction in c
Function in c
 
Array Cont
Array ContArray Cont
Array Cont
 
Fundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptxFundamentals of functions in C program.pptx
Fundamentals of functions in C program.pptx
 
C function
C functionC function
C function
 
Function in c program
Function in c programFunction in c program
Function in c program
 
Unit 4 (1)
Unit 4 (1)Unit 4 (1)
Unit 4 (1)
 
Function in C program
Function in C programFunction in C program
Function in C program
 
Functions in C
Functions in CFunctions in C
Functions in C
 
Functions (Computer programming and utilization)
Functions (Computer programming and utilization)Functions (Computer programming and utilization)
Functions (Computer programming and utilization)
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
Functions
FunctionsFunctions
Functions
 
Unit iv functions
Unit  iv functionsUnit  iv functions
Unit iv functions
 
Functionincprogram
FunctionincprogramFunctionincprogram
Functionincprogram
 
Functions and pointers_unit_4
Functions and pointers_unit_4Functions and pointers_unit_4
Functions and pointers_unit_4
 
6.3 c-Functions.ppt
6.3 c-Functions.ppt6.3 c-Functions.ppt
6.3 c-Functions.ppt
 
unit_2.pptx
unit_2.pptxunit_2.pptx
unit_2.pptx
 
Fucntions & Pointers in C
Fucntions & Pointers in CFucntions & Pointers in C
Fucntions & Pointers in C
 
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptxUnit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
Unit_5Functionspptx__2022_12_27_10_47_17 (1).pptx
 

Recently uploaded

會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
中 央社
 

Recently uploaded (20)

TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
TỔNG HỢP HƠN 100 ĐỀ THI THỬ TỐT NGHIỆP THPT TOÁN 2024 - TỪ CÁC TRƯỜNG, TRƯỜNG...
 
PSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptxPSYPACT- Practicing Over State Lines May 2024.pptx
PSYPACT- Practicing Over State Lines May 2024.pptx
 
How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17How To Create Editable Tree View in Odoo 17
How To Create Editable Tree View in Odoo 17
 
How to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 InventoryHow to Manage Closest Location in Odoo 17 Inventory
How to Manage Closest Location in Odoo 17 Inventory
 
MOOD STABLIZERS DRUGS.pptx
MOOD     STABLIZERS           DRUGS.pptxMOOD     STABLIZERS           DRUGS.pptx
MOOD STABLIZERS DRUGS.pptx
 
diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....diagnosting testing bsc 2nd sem.pptx....
diagnosting testing bsc 2nd sem.pptx....
 
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinhĐề tieng anh thpt 2024 danh cho cac ban hoc sinh
Đề tieng anh thpt 2024 danh cho cac ban hoc sinh
 
The Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDFThe Story of Village Palampur Class 9 Free Study Material PDF
The Story of Village Palampur Class 9 Free Study Material PDF
 
Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...Andreas Schleicher presents at the launch of What does child empowerment mean...
Andreas Schleicher presents at the launch of What does child empowerment mean...
 
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
Envelope of Discrepancy in Orthodontics: Enhancing Precision in Treatment
 
Major project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategiesMajor project report on Tata Motors and its marketing strategies
Major project report on Tata Motors and its marketing strategies
 
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽會考英聽
 
Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"Mattingly "AI and Prompt Design: LLMs with NER"
Mattingly "AI and Prompt Design: LLMs with NER"
 
“O BEIJO” EM ARTE .
“O BEIJO” EM ARTE                       .“O BEIJO” EM ARTE                       .
“O BEIJO” EM ARTE .
 
ANTI PARKISON DRUGS.pptx
ANTI         PARKISON          DRUGS.pptxANTI         PARKISON          DRUGS.pptx
ANTI PARKISON DRUGS.pptx
 
An overview of the various scriptures in Hinduism
An overview of the various scriptures in HinduismAn overview of the various scriptures in Hinduism
An overview of the various scriptures in Hinduism
 
male presentation...pdf.................
male presentation...pdf.................male presentation...pdf.................
male presentation...pdf.................
 
UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024UChicago CMSC 23320 - The Best Commit Messages of 2024
UChicago CMSC 23320 - The Best Commit Messages of 2024
 
demyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptxdemyelinated disorder: multiple sclerosis.pptx
demyelinated disorder: multiple sclerosis.pptx
 
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
Mattingly "AI and Prompt Design: LLMs with Text Classification and Open Source"
 

Call by value

  • 1. CALL BY VALUE & CALL BY REFERNCE TOPIC: PRESENTED BY DHARANI
  • 2. THERE ARE TWO WAYS IN WHICH WE CAN PASS ARGUMENTS TO THE FUNCTION
  • 3. CALL BY VALUE  Value of actual arguments passed to the formal arguments. Any change made in the formal arguments does not effect the actual arguments. When function is called it does not affect the actual contents of the actual arguments.
  • 4. #include <stdio.h> void call_by_value(int x) { printf("Inside call_by_value x = %d before adding 10.n", x); x += 10; printf("Inside call_by_value x = %d after adding 10.n", x); } int main() { int a=10; printf("a = %d before function call_by_value.n", a); call_by_value(a); printf("a = %d after function call_by_value.n", a); return 0; } EXAMPLE PROGRAM
  • 5. OUTPUT OF THE PROGRAM a = 10 before function call_by_value. Inside call_by_value x = 10 before adding 10. Inside call_by_value x = 20 after adding 10. a = 10 after function call_by_value.
  • 6. Actual and Formal arguments  Arguments passed to the function during function call are known as actual arguments  The arguments we use during a function definition are known as formal arguments.
  • 7. For a function call to be valid the type, order and number of actual and formal arguments must always be same.  Value of each of the actual arguments in the calling function is copied into the formal arguments of the called function. Changes made have no effect on the values of actual arguments in the calling function. Concept of Actual and Formal arguments
  • 8. CALL BY VALUE CALL BY REFERENCE CALLING FUNCTION SENDS COPIES TO DATA. THE FORMAL PARAMETERS ARE ORDINARY VARIABLES. ATMOST ONLY ONE VALUES CAN BE SENT BACK TO THE CALLING FUNCTION. ACTUAL PARAMETERS ARE AFFECTED BY CHANGES MADE WITHIN THE FUNCTION. CALLING FUNCTION SENDS ADDRESS OF DATA. THE FORMAL PARAMETERS ARE POINTER VARIABLE. SEVERAL RESULTS CAN BE SENT BACK TO THE CALLING FUNCTION. DIRECT CHANGES ARE MADE TO THE ACTUAL PARAMETERS.