Compute Area and Circumference of Circle.
May 30, 2012 at 2:23am May 30, 2012 at 2:23am UTC
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 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81
// ProgrammingAssignmentSeven.cpp : Defines the entry point for the console application.
//
#include "stdafx.h"
#include <iostream>
#include <cmath>
using namespace std;
const double PI = 3.14;
// ===================
// Function Prototypes
// ===================
void Banner();
void Getvalue(double &);
double computeCircumference(double );
void computeArea(double &, double );
// ===============
int main() {
double c;
double radius = 0;
double area = 0;
double a;
Banner();
Getvalue(radius);
c = computeCircumference(radius);
a = computeArea(radius,area);
cout << c << endl;
cout << a << endl;
return 0;
} // Function Main
// ==================
// ==================
void Banner() {
cout << "================================================" << endl;
cout << "Welcome to my Programming Assignment Seven. " << endl;
cout << endl;
cout << "Please Enter a value for the radius of a circle." << endl;
cout << "I will tell the circumference and area of it. " << endl;
cout << "================================================" << endl;
cout << endl;
} // Function Banner
// ===================
// ==================
void Getvalue(double & radius2) {
cout << "Please enter your radius of a circle: " ;
cin >> radius2;
} // Funciton Getvalue
// ======================
// ====================
double computeCircumference( double radius1) {
double c;
c = 2*PI*radius1;
return c;
}// Function computecircumference
// =================================
// ================
void computeArea(double radius2, double & a) {
a = PI*pow(radius2,2);
}
cannot convert from 'void' to 'double' This happens at the line 30.
The program does compute the Circumference, and I am trying to compute the Area, but it doesn't work. Please help me ^_^
Thank you.
May 30, 2012 at 3:37am May 30, 2012 at 3:37am UTC
computeArea does not return anything, but you are trying to get a return value from it on line 30.
Topic archived. No new replies allowed.