Call by Address Example 2| Pointers in C | Data Structure Using C

TL;DR
A program is explained that demonstrates the concepts of call by address and call by value, using pointers and integer parameters.
Transcript
hello dear students let's see one more example program which will explain call by address and call by value now notice in this program we have been given a function f1 again where the first parameter is a pointer but the second parameter is not a pointer it is a simple integer pointer so it is but obvious that the first parameter will always receiv... Read More
Key Insights
- 👻 Call by address involves passing the address of a variable, allowing modifications to be made to the original variable.
- 🧭 Call by value involves passing the value of a variable, creating a copy of the original variable.
- ❓ Modifying a pointer in a function will affect the original variable, but modifying an integer parameter will not.
- ❤️🩹 When a function ends, the parameters created inside the function are destroyed.
- ❣️ The values of x and y in the main function are not affected by the modifications made inside the function.
- 🏪 Pointers can store addresses of variables, while integer parameters can store values of variables.
- ❓ The output of the program depends on the concepts of call by address and call by value.
Install to Summarize YouTube Videos and Get Transcripts
Explore YouTube Video Summarizer or Get YouTube Transcript Extractor
Questions & Answers
Q: What is the difference between call by address and call by value?
Call by address involves passing the address of a variable, while call by value involves passing the value of a variable. In call by address, any changes made to the variable inside the function will affect the original variable. In call by value, changes made inside the function will not affect the original variable.
Q: How does the program handle the first call to the function?
In the first call, the address of x is passed as the first parameter, and the value of y is passed as the second parameter. Inside the function, the pointer p1 will point to the address of x, while the integer parameter p2 will store the value of y. The values of x and y are then modified independently.
Q: What happens when the function ends?
When the function ends, the parameters p1 and p2 are destroyed. The program returns to the main function with the updated values of x and y. Any changes made to p1 and p2 inside the function will not affect the values of x and y in the main function.
Q: How does the program handle the second call to the function?
In the second call, the address of y is passed as the first parameter, and the value of x is passed as the second parameter. Similar to the first call, p1 will point to the address of y, and p2 will store the value of x. The values of y and x are then modified independently.
Summary & Key Takeaways
-
The program demonstrates call by address and call by value, with the first parameter receiving an address and the second parameter receiving a value.
-
The values of x and y in the main function are 10 and 20, respectively.
-
The program shows how the values of x and y are affected when passed to the function using call by address and call by value.
Read in Other Languages (beta)
Share This Summary 📚
Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator
Explore More Summaries from Ekeeda 📚






Summarize YouTube Videos and Get Video Transcripts with 1-Click
Try YouTube Summary with ChatGPT & Claude or YouTube Transcript Generator