Question
When I use an online c++ compiler, my code runs fin (without error) but ouputs 0.0 as my area instead of the acutal mathematical answer,,
When I use an online c++ compiler, my code runs fin (without error) but ouputs 0.0 as my area instead of the acutal mathematical answer,, what am I doing wrong?
C++ code being used:
#include
double const PI = 3.141592; void getDataa(double base, double height); void getData(double radiusa, double radiusb); void printData(double rec_area, double elli_area);
int main() { double base, height, radiusa, radiusb, rec_area, elli_area;
cout << "For the rectangle" << endl;
getDataa(base, height);
cout << "For the ellipse" << endl;
getData(radiusa, radiusb);
rec_area = base * height; elli_area = PI * radiusa * radiusa;
printData(rec_area, elli_area);
return 0; }
void getDataa(double base, double height) { cout << "Please enter two lengths " << endl; cin >> base; cin >> height; }
void getData(double radiusa, double radiusb) { cout << "Please enter two lenghts " << endl; cin >> radiusa; cin >> radiusb; }
void printData(double rec_area, double elli_area) { cout << "The area of the rectangle is "; cout << fixed << setprecision(1) << rec_area << endl; cout << "The area of the ellipse is "; cout << fixed << setprecision(1) << elli_area << endl; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started