IN ORDER TO IMPLEMENT A SET OF RULES / TUTORIALOUTLET DOT COM IN ORDER TOIMPLEMENTASETOFRULES/TUTORIALOUTLET.COM | Page 15
cout << endl << ―gnum1=‖ << gnum1 <<
―\tgnum2=‖ << gnum2;
return 0;
} Exercise F2*
Write a void function without parameters computeAreaPeri that
computes the area and the perimeter of
a circle which are output in function main.
a. Function main first calls function computeAreaPeri to compute the
area and the perimeter of the
circle with radius 5.43.
b. It then reads the radius of a circle and then calls function
computeAreaPeri again to compute the
area and the perimeter of this circle.
You must first determine and define the global variables of this
program; then write function
computeAreaPeri, and finally write function main. Exercise F3
Execute the following program and show its output for the input value
15:
#include <iostream>
using namespace std;
int gnum1, gnum2; ©2011 Gilbert Ndjatou Page 172 void funct(void)
{
int num = 2 * gnum1 + 5;
gnum2 = gnum1 + num;
gnum1 = gnum2 + 10;
}
int main( )
{
gnum1 = 25;
funct( );
cout << endl << ―gnum1=‖ << gnum1 <<
―\tgnum2=‖ << gnum2;
cin >> gnum1;
funct( );
cout << endl << ―gnum1=‖ << gnum1 <<
―\tgnum2=‖ << gnum2;
return 0;