In Chapter 6, we have discussed two function parameter passing techniques available C++ : pass by va

In Chapter 6, we have discussed two function parameter passing techniques available C++ : pass by value, pass by reference. Read lecture notes that further illustrate these two function parameter passing techniques and scope of variables. Then, study the following program and answer following questions.

#include
using namespace std;
void swapValue(int , int);
void swapReference(int &, int &);

int main ()

Save your time - order a paper!

Get your paper written from scratch within the tight deadline. Our service is a reliable solution to all your troubles. Place an order on any task and we will take care of it. You won’t have to worry about the quality and deadlines

Order Paper Now

{
int i =10,n = 20;
swapValue(i, n);
cout

i =10,n = 20;
swapReference(i, n);
coutreturn 0; }

void swapValue(int a, int b)

{
int temp = a;

a =b ;

b = a; }

void swapReference(int &a, int &b) { int temp = a; a = b; b = temp;

}

a) What is the output of the cout statement 1 above?

b) What is the output of the cout statement 2 above?

c) Briefly explain your answer to questions (a) and (b) ?

 

Looking for a Similar Assignment? Let us take care of your classwork while you enjoy your free time! All papers are written from scratch and are 100% Original. Try us today! Use Code FREE15