Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please Help! using c++, give full code, thanks! Create the design for a program

ID: 3697223 • Letter: P

Question

Please Help! using c++, give full code, thanks!

Create the design for a program that shows the scope of global and local variables. Your design should have three functions—main, parameters, and useGlobals. You should have two global integer variables named num1 initialized to 10 and num2 initialized to -5. Your main function should have the following characteristics:

• Begin the program block

• Declare two local variables—num1 initialized to 20 and num2 initialized to 13

• Call the function parameters with the actual arguments num1 and num2

• Call the function parameters with the actual arguments num2 and num1

• Call the function useGlobals with no actual arguments

• Begin another program block

• Declare two local variables—num1 initialized to 94 and num2 initialized to 50 • Call the function parameters with the actual arguments num1 and num2 • Call the function parameters with the actual arguments num2 and num1 • Call the function useGlobals with no actual arguments

• End the second block

• Call the function parameters with the actual arguments num1 and num2

• Call the function parameters with the actual arguments num2 and num1

• Call the function useGlobals with no actual arguments

• Before each function call, display a message showing the value of num1 and num2

• After calling each function, display a message showing the value of num1 and num2 Your parameters function should have the following characteristics: • Have the data type void • Have two formal integer parameters num1 and num2

• Display a message showing the value of num1 and num2. In main, create two local integer variables named num1 and num2 Your useGlobals function should have the following characteristics:

• Have the data type void

• Have no formal parameters

• Display a message showing the value of num1 and num2. In main, create two local integer variables named num1 and num2

Explanation / Answer

Hello. Please find the required code below. Fully tested and works fine. Hope you are satisfied. Good luck.

#include<bits/stdc++.h>
using namespace std;
int num1=10,num2=-5;
void useGlobals() {
   cout<<"num1 and num2 after function call to useGlobals are : "<<num1<<" "<<num2<<endl;
   }
  
void parameters(int num1,int num2)
{
   cout<<"num1 and num2 after function call to parameters are : "<<num1<<" "<<num2<<endl;
   }
int main()
{
   {
       int num1=20,num2=13;
   cout<<"num1 and num2 before function call to parameters are : "<<num1<<" "<<num2<<endl;
   parameters(num1,num2);
   cout<<"num2 and num1 before 2nd function call to parameters are : "<<num2<<" "<<num1<<endl;
   parameters(num2,num1);
   cout<<"num1 and num2 before function call to useGlobals : "<<num1<<" "<<num2<<endl;
   useGlobals();
   }
   {
   int num1=94,num2=50;
   cout<<"num1 and num2 before function call to parameters in 2nd block are : "<<num1<<" "<<num2<<endl;
   parameters(num1,num2);
//   cout<<"num1 and num2 after function call to parameters in 2nd block are : "<<num1<<num2<<endl;
   cout<<"num2 and num1 before 2nd function call to parameters in 2nd block are : "<<num2<<" "<<num1<<endl;
   parameters(num2,num1);
   cout<<"num1 and num2 before function call to useGobals in 2nd block are : "<<num1<<" "<<num2<<endl;
   useGlobals();
   }
   {
//   int num1=94,num2=50;
cout<<"num1 and num2 before function call to parameters in 3rd block are : "<<num1<<" "<<num2<<endl;
   parameters(num1,num2);
   cout<<"num2 and num1 before 2nd function call to parameters in 3rd block are : "<<num2<<" "<<num1<<endl;
   parameters(num2,num1);
   cout<<"num1 and num2 before function call to useGobals in 3rd block are : "<<num1<<" "<<num2<<endl;
   useGlobals();
   }
  
   return 0;
   }