Parameter passing methods

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:
  1. They can receive data from the corresponding actual parameter, called in mode.
  2. They  can transmit data to the actual parameter, called out mode.
  3. They  can do both, called inout mode.

2. Implementation Models of Parameter Passing: This model consist the following ways of parameter passing.
  1. Pass by value
  2. Pass by reference
  3. Pass-by-Result
  4. Pass-by-Value-Result
  5. 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;

}

Principles of Programming Languages

EasyExamNotes.com covered following topics in PPL.

Practicals:
Previous years solved papers:
A list of Video lectures
References:
  1. Sebesta,”Concept of programming Language”, Pearson Edu 
  2. Louden, “Programming Languages: Principles & Practices” , Cengage Learning 
  3. Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill. 
  4. E Horowitz, "Programming Languages", 2nd Edition, Addison Wesley

Python Programming ↓ 👆
Java Programming ↓ 👆
JAVA EasyExamNotes.com covered following topics in these notes.
JAVA Programs
Principles of Programming Languages ↓ 👆
Principles of Programming Languages
EasyExamNotes.com covered following topics in these notes.

Practicals:
Previous years solved papers:
A list of Video lectures References:
  1. Sebesta,”Concept of programming Language”, Pearson Edu 
  2. Louden, “Programming Languages: Principles & Practices” , Cengage Learning 
  3. Tucker, “Programming Languages: Principles and paradigms “, Tata McGraw –Hill. 
  4. E Horowitz, "Programming Languages", 2nd Edition, Addison Wesley

    Computer Organization and Architecture ↓ 👆

    Computer Organization and Architecture 

    EasyExamNotes.com covered following topics in these notes.

    1. Structure of desktop computers
    2. Logic gates
    3. Register organization
    4. Bus structure
    5. Addressing modes
    6. Register transfer language
    7. Direct mapping numericals
    8. Register in Assembly Language Programming
    9. Arrays in Assembly Language Programming

    References:

    1. William stalling ,“Computer Architecture and Organization” PHI
    2. Morris Mano , “Computer System Organization ”PHI

    Computer Network ↓ 👆
    Computer Network

    EasyExamNotes.com covered following topics in these notes.
    1. Data Link Layer
    2. Framing
    3. Byte count framing method
    4. Flag bytes with byte stuffing framing method
    5. Flag bits with bit stuffing framing method
    6. Physical layer coding violations framing method
    7. Error control in data link layer
    8. Stop and Wait scheme
    9. Sliding Window Protocol
    10. One bit sliding window protocol
    11. A protocol Using Go-Back-N
    12. Selective repeat protocol
    13. Application layer
    References:
    1. Andrew S. Tanenbaum, David J. Wetherall, “Computer Networks” Pearson Education.
    2. Douglas E Comer, “Internetworking with TCP/IP Principles, Protocols, And Architecture",Pearson Education
    3. KavehPahlavan, Prashant Krishnamurthy, “Networking Fundamentals”, Wiley Publication.
    4. Ying-Dar Lin, Ren-Hung Hwang, Fred Baker, “Computer Networks: An Open Source Approach”, McGraw Hill.