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

#include <iostream> #include <iomanip> using namespace std; // This program will

ID: 3883645 • Letter: #

Question

#include <iostream>

#include <iomanip>

using namespace std;

// This program will demonstrate the scope rules.

// PLACE YOUR NAME HERE

const double PI = 3.14;

const double RATE = 0.25;

void findArea(float, float&);

void findCircumference(float, float&);

int main()

{

       cout << fixed << showpoint << setprecision(2);

       float radius = 12;

      

       cout <<" Main function outer block" << endl;

       cout <<" LIST THE IDENTIFIERS THAT are active here" << endl << endl;

       {

              float area;

              cout << "Main function first inner block" << endl;      

              cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;

             

              // Fill in the code to call findArea here

             

              cout << "The radius = " << radius << endl;

              cout << "The area = " << area << endl << endl;

       }

       {

        float radius = 10;

              float circumference;

             

              cout << "Main function second inner block" << endl;

              cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;

             

              // Fill in the code to call findCircumference here

             

              cout << "The radius = " << radius << endl;

              cout << "The circumference = " << circumference << endl << endl;

             

       }

      

       cout << "Main function after all the calls" << endl;

       cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;

         

       return 0;

}

// *********************************************************************

//                           findArea

//  

//   task:     This function finds the area of a circle given its radius

//   data in: radius of a circle

//   data out: answer (which alters the corresponding actual parameter)

//

//   ********************************************************************

void findArea(float rad, float& answer)

{

      

       cout << "AREA FUNCTION" << endl << endl;

       cout << "LIST THE IDENTIFIERS THAT are active here"<< endl << endl;

      

       // FILL in the code, given that parameter rad contains the radius, that

       // will find the areato be stored in answer

      

}

// ******************************************************************************

//                           findCircumference

//  

//   task:     This function finds the circumference of a circle given its radius

//   data in: radius of a circle

//   data out: distance (which alters the corresponding actual parameter)

//

//   *****************************************************************************

void findCircumference(float length, float& distance)

{

       cout << "CIRCUMFERENCE FUNCTION" << endl << endl;

       cout << "LIST THE IDENTIFIERS THAT are active here" << endl << endl;

      

       // FILL in the code, given that parameter length contains the radius,

       // that will find the circumference to be stored in distance

      

}

Exercise 1: Fill in the following chart by listing the identifiers (function names, variables, constants) GLOBALMain Main Main Area Circum- (inner 1)(inner 2) Exercise 2: For each cout instruction that reads: cout

Explanation / Answer

Below is your code. Let me know if you have any issues.

#include <iostream>

#include <iomanip>

using namespace std;

const double PI = 3.14;

const double RATE = 0.25;

void findArea(float, float&);

void findCircumference(float, float&);

int main()

{

cout << fixed << showpoint << setprecision(2);

float radius = 12;

cout <<"Main function outer block" << endl;

cout <<" PI, RATE, findArea, findCircumference, radius"

" are active here" << endl << endl;

{

float area;

cout << "Main function first inner block" << endl;

cout << " PI, RATE, findArea, findCircumference, radius, area"

" are active here" << endl << endl;

findArea(radius, area);

cout << "The radius = " << radius << endl;

cout << "The area = " << area << endl << endl;

}

{

float radius = 10;

float circumference;

cout << "Main function second inner block" << endl;

cout << " PI, RATE, findArea, findCircumference, radius (local), "

" circumference are active here" << endl << endl;

findCircumference(radius, circumference);

cout << "The radius = " << radius << endl;

cout << "The circumference = " << circumference << endl << endl;

}

cout << "Main function after all the calls" << endl;

cout << " PI, RATE, findArea, findCircumference, radius"

" are active here" << endl << endl;

return 0;

}

// *********************************************************************

// findArea

//

// task: This function finds the area of a circle given its radius

// data in: radius of a circle

// data out: answer (which alters the corresponding actual parameter)

//

// ********************************************************************

void findArea(float rad, float& answer)

{

cout << "AREA FUNCTION" << endl;

cout << " PI, RATE, findArea, findCircumference, rad, answer"

" are active here" << endl << endl;

// FILL in the code, given that parameter rad contains the radius, that

// will find the areato be stored in answer

answer = PI * rad * rad;

}

// ******************************************************************************

// findCircumference

//

// task: This function finds the circumference of a circle given its radius

// data in: radius of a circle

// data out: distance (which alters the corresponding actual parameter)

//

// *****************************************************************************

void findCircumference(float length, float& distance)

{

cout << "CIRCUMFERENCE FUNCTION" << endl;

cout << " PI, RATE, findArea, findCircumference, length, distance"

" are active here" << endl << endl;

// FILL in the code, given that parameter length contains the radius,

// that will find the circumference to be stored in distance

distance = 2 * PI * length;

}

Sample Run

Main function outer block
PI, RATE, findArea, findCircumference, radius are active here

Main function first inner block
PI, RATE, findArea, findCircumference, radius, area are active here

AREA FUNCTION
PI, RATE, findArea, findCircumference, rad, answer are active here

The radius = 12.00
The area = 452.16

Main function second inner block
PI, RATE, findArea, findCircumference, radius (local),
circumference are active here

CIRCUMFERENCE FUNCTION
PI, RATE, findArea, findCircumference, length, distance are active here

The radius = 10.00
The circumference = 62.80

Main function after all the calls
PI, RATE, findArea, findCircumference, radius are active here


--------------------------------
Process exited after 0.2503 seconds with return value 0
Press any key to continue . . .