Explain Call by Value in C language ?
Call by value
- In call by value, original value is not modified.
- In call by value, value being passed to the function is locally stored by the function parameter in stack memory location. If you change the value of function parameter, it is changed for the current function only.
- It will not change the value of variable inside the caller method such as main().
Sample Code
#include<stdio.h>
void change(int num)
{
printf("Before adding value inside function num=%d \n",num);
num=num+100;
printf("After adding value inside function num=%d \n", num);
}
int main()
{
int x=100;
printf("Before function call x=%d \n", x);
change(x);//passing value in function
printf("After function call x=%d \n", x);
return 0;
}
Output
Before function call x=100
Before adding value inside function num=100
After adding value inside function num=200
After function call x=100
Categorized in:
Tagged in:
Accentur interview questions and answers, Applied Materials interview questions and answers, Asian Paints Ltd. interview questions and answers, Bosch India Software interview questions and answers, C Program to Implement Call By Value using Functions, call by reference program in c, call by value, call by value and call by reference, Call by Value and Call by Reference in C, call by value and call by reference in c language in hindi, call by value and call by reference in java, call by value and call by reference program in c, call by value c++, call by value definition, call by value example, call by value in c, call by value in java, call by value program in c, Capgemini interview questions and answers, CASTING NETWORKS INDIA PVT LIMITED interview questions and answers, CGI Group Inc interview questions and answers, Chetu interview questions and answers, Ciena Corporation interview questions and answers, Collabera Technologies interview questions and answers, Dell International Services India Pvt Ltd interview questions and answers, describe call by value function, DHFL Pramerica Life Insurance Company Ltd interview questions and answers, difference between call by value and call by reference, Difference Between Call by Value and Reference in C, Elico HealthCare Services Ltd interview questions and answers, Flipkart interview questions and answers, function call by value, Function call by Value in C, Function call by value in C programming, HCL Technol interview questions and answers, IBM interview questions and answers, Indecomm Global Services interview questions and answers, Mavenir interview questions and answers, Mphasis interview questions and answers, NetApp interview questions and answers, Oracle Corporation interview questions and answers, PeopleStrong interview questions and answers, plintron interview questions and answers, R Systems interview questions and answers, Raqmiyat Information Technologies Pvt Ltd interview questions and answers, Reliance Industries Ltd interview questions and answers, SAP Labs India Pvt Ltd interview questions and answers, Tata AIA Life Insurance interview questions and answers, Tech Mahindr interview questions and answers, The Linde Group interview questions and answers, what is call by value