Half done, but seems complete to me

My Professor said i'm only half done, what does she mean because she isn't making sense.

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
 /***************************************************************************************************************************************
Function 1: Call a function that will read in and return the radius

Function 2:  Pass the radius to the circumference function and return the circumference to main.

Function 3: Pass the radius to the area function and return the area to main.

Main will now print the two answers.

Function 4: Pass the radius to the function, but this time, the function will calculate and return both the circumfernece and the area.

Main will once again print the circumference and the area.
****************************************************************************************************************************************/
 //c=2(pi)r

#include <iostream>
#include <iomanip>
using namespace std;


double radius(double& r)
{
	cout << "Enter a radius: ";
	cin >> r;
	return r;
}

double circ(double& c, double& r)
{
	r = radius(r);
	c = 2 * (3.14) * r;
	return c;
}

double area(double& a, double& r)
{
	r = radius(r);
	a = 2 * 3.14 * r * r;
	return a;
}

int main()
{
	
	double c, r, a;
	cout << fixed << setprecision(2);
	cout << "Hi there!" << endl;
	c = circ(c, r);
	a = area(a, r);
	cout << "The Circumference is: "<< c << endl;
	cout << "The Area is: "  << a << endl;

	
	return 0;
}

In your main function you are passing uninitialised variables to the circ and area functions.
// Function 2: Pass the radius to the circumference function and return the circumference to main.
This description implies, that the circ function should not get it's input from the user. It should only handle input passed to it as argument. This means circ should never call radius internally.

//Function 3: Pass the radius to the area function and return the area to main.
Exactly the same case.
Last edited on
Topic archived. No new replies allowed.