Hi everyone,

I'm typing up a program that allows the input of the radius and height of a cylinder and outputs the total surface area, lateral surface area, and volume of the cylinder. I've typed up the skeleton of the program and I'm just fixing up errors but I can't figure this one out.#include <iostream> #include <cmath> using namespace std; double totalSurfaceArea(double r, double h); double lateralSurfaceArea(double r, double h); double volume (double r, double h); int main() { double r, h; double tArea, lArea, v; const double PI = 3.14159265; cout << "This program will calculate the total surface area, lateral surface area, and volume of a right-circular cylinder. \n Please enter the radius and height of the cylinder. \n"; cin >> r >> h; tArea = totalSurfaceArea (r, h); lArea = lateralSurfaceArea (r, h); v = volume (r, h); cout << "The total surface area is: " << tArea << "; the lateral surface area is: " << lArea << "; and the volume is " << v << "."; std::cin.clear(); std::cin.ignore(); getchar(); return 0; } const double PI = 3.14159265; double totalSurfaceArea (double r, double h) { double tArea; tArea = 2*PI*r(r+h); //error is in the first r return tArea; } double lateralSurfaceArea (double r, double h) { double lArea; lArea = 2*PI*r*h; return lArea; } double volume (double r, double h) { double v; v = PI(pow(r,2))*h; //error is in the PI return v; }

The type of error is "term does not evaluate to a function taking 1 argument" in both cases, and if I hover over the 'r' or 'PI' the error says "expression must have (pointer-to-) function type." I am something of a novice programmer in C++, so using simple terms is most helpful. Thanks in advance.

p.s. Apologies for the poor format copy/paste has left you)

edited by moderator: Added pre tags. -Razor2.3

tArea = 2*PI*r(r+h); //error is in the first r

You're trying to call functionr, instead of multiplyingrandr+h, also I don't think that's the correct formula. Replace with:tArea = 2 * PI * r * r + 2 * PI * r * h;

v = PI(pow(r,2))*h; //error is in the PI

Same deal, and it looks like you could avoid including cmath if you changed the line to:v = PI * r * r * h;

Thank you for your help!

Ask Your Question

Weekly Poll

Do you think Google should sell budget phones in the US?

Discuss in The Lounge

Poll History