Question: Please explain your solution. You are given the source code below. You are going to assign the last 2 digits of your student number into
Please explain your solution.
You are given the source code below. You are going to assign the last 2 digits of your student number into the variable myStudentIDLast2Digits. Answer questions a) and b) below.
Two digit -> "30"
#include
using namespace std;
void myFunc ();
void yourFunc ();
int myStudentIDLast2Digits = _____; //Put the last 2 digits of your student number here.
int w = myStudentIDLast2Digits + 1;
int x = myStudentIDLast2Digits + 2;
int y = myStudentIDLast2Digits + 3;
int z = myStudentIDLast2Digits + 4;
int main (){
int w = 111;
int x = 222;
int y = 333;
int z = 444;
// **1** //
cout << "myStudentIDLast2Digits =" << myStudentIDLast2Digits << endl;
cout << "**1** :";
cout << w << " " << x << " " << y << " " << z << endl; //prints w,x,y,z
myFunc ();
return 0;
}
void myFunc (){
int w = 100;
int x = 200;
// **2** //
cout << "**2** :";
cout << w << " " << x << " " << y << " " << z << endl;
yourFunc ();
}
void yourFunc (){
int x = 2000;
int y = 3000;
// **3** //
cout << "**3** :";
cout << w << " " << x << " " << y << " " << z << endl;
}
a) Assuming that the above is a C++ program, and what will be printed? Remember that C++ is statically scoped.
myStudentIDLast2Digits = ____
**1** :
**2** :
**3** :
b) Now assume that the source code given above is not a C++ program but a CDS++ program, where CDS++ is a language that is identical to C++ except that it is dynamically scoped. What will be printed in that case.
myStudentIDLast2Digits = _____
**1** :
**2** :
**3** :
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
