PARAMETER PASSING METHODS
Parameter-passing methods are the ways in which parameters are transmitted to and/or from called subprograms.
Parameter passing depends on model of subprogram.There are two models for parameter passing-
1. Semantics Models of Parameter Passing
2. Implementation Models of Parameter Passing
1. Semantics Models of Parameter Passing: Formal parameters are characterized by one of three distinct semantics models:
- They can receive data from the corresponding actual parameter, called in mode.
- They can transmit data to the actual parameter, called out mode.
- They can do both, called inout mode.
2. Implementation Models of Parameter Passing: This model consist the following ways of parameter passing.
- Pass by value
- Pass by reference
- Pass-by-Result
- Pass-by-Value-Result
- Pass-by-Name
1. Pass by value: Value of actual parameter in read only mode is transmitted to formal parameters.
2. Pass by reference: Reference/address of actual parameter is transmitted to formal parameters.
3. Pass-by-Result: When a parameter is passed by result, no value is transmitted to the subprogram.
4. Pass-by-Value-Result: Pass-by-value-result is an implementation model for inout-mode parameters. Pass-by-value-result is sometimes called pass-by-copy, because the actual
parameter is copied to the formal parameter at subprogram entry and then
copied back at subprogram termination.
5. Pass-by-Name: Pass-by-name is an inout-mode parameter transmission method. In it parameters are passed by name. Implementing a pass-by-name parameter requires a subprogram to be passed to the called subprogram to evaluate the address or value of the formal parameter.
Program examples:
Call by value:
#include <iostream>
using namespace std;
void show(int x)
{
cout<<x<<endl;
}
int main()
{
int age = 20;
show(age);
show(10);
return 0;
}
Call by reference:
#include <iostream>
using namespace std;
void show(int *x)
{
cout<<*x<<endl;
}
int main()
{
int age = 20;
show(&age);
return 0;
}
EasyExamNotes.com covered following topics in these notes.
Principles of Programming Languages:
EasyExamNotes.com covered following topics in these notes.
- Language Evaluation Criteria
- Influences on Language Design
- Language Categories
- Programming Paradigms
- Compilation
- Virtual Machines
- Programming Environments
- Issues in Language Translation
- Parse Tree
- Pointer and Reference type
- Concept of Binding
- Type Checking
- Strong typing
- Sequence control with Expression
- Exception Handling
- Subprograms
- Fundamentals of sub-programs
- Scope and lifetime of variable
- Static and dynamic scope
- Design issues of subprogram and operations
- Local referencing environments
- Parameter passing methods
- Overloaded sub-programs
- Generic sub-programs
- Design issues for functions
- Co routines
- Abstract Data types
- Abstraction and encapsulation
- Static and Stack-Based Storage management
- Garbage Collection
- OOP in C++
- OOP in Java
- OOP in C#
- OOP in PHP
- Concurrency
- Semaphores
- Monitors
- Message passing
- Java threads
- C# threads
- Exception handling
- Exceptions
- Exception Propagation
- Exception handler in C++
- Exception handler in Java
- Introduction and overview of Logic programming
- Basic elements of Prolog
- Application of Logic programming
- Functional programming languages
- Introduction to 4GL
Practicals:
- Memory Implementation of 2D Array.
- Memory Implementation of 3D Array.
- Implementation of pointers in C++.
- Write a program in Java to implement exception handling.
- Write a program in C++ to implement call by value parameter passing Method.
- Write a program in C++ to implement call by reference parameter passing Method.
- Write a program in Java to implement concurrent execution of a job using threads.
- Implement Inheritance in C#.
- Implement Encapsulation in C#.
- Implement static/compiletime Polymorphism in C#.
- Implement dynamic/runtime Polymorphism in C#.
Previous years solved papers:
A list of Video lectures
References:
- Sebesta,”Concept of programming Language”, Pearson Edu
- Louden, “Programming Languages: Principles & Practices” , Cengage Learning
- Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill.
- E Horowitz, "Programming Languages", 2nd Edition, Addison Wesley
- Memory Implementation of 2D Array.
- Memory Implementation of 3D Array.
- Implementation of pointers in C++.
- Write a program in Java to implement exception handling.
- Write a program in C++ to implement call by value parameter passing Method.
- Write a program in C++ to implement call by reference parameter passing Method.
- Write a program in Java to implement concurrent execution of a job using threads.
- Implement Inheritance in C#.
- Implement Encapsulation in C#.
- Implement static/compiletime Polymorphism in C#.
- Implement dynamic/runtime Polymorphism in C#.
Previous years solved papers:
A list of Video lectures
References:
References:
- Sebesta,”Concept of programming Language”, Pearson Edu
- Louden, “Programming Languages: Principles & Practices” , Cengage Learning
- Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill.
- E Horowitz, "Programming Languages", 2nd Edition, Addison Wesley