I am new to C++ and programming in general, and am working on an upcoming homework assignment. I have run into several problems and would greatly appreciate assistance. The assignment is to write a code to determine area and volume in C++, using a While Loop. I am stuck with the while statement, I am not sure how to state when I want it to stop. Below is what I have so far.
#include <iostream>
using namespace std;
int area (int l, int w); // function prototype
int volume (int l, int w, int d); // function prototype
int main (int argc, char* argv[]) {
int length, width, depth; // parameters for the areas and volumes
int result; //result is output
cout << endl;
// read in the values of length, width, and depth
While (?)
{
cout << "If you want the result of the calculation to be an area,";
cout << endl;
cout << "place a 0 in the depth parameter ";
cout << endl << endl;
cout << "Enter a length (postive integer): ";
cin >> length;
cout << "Enter a width (postive integer): ";
cin >> width;
cout << "Enter a depth (postive integer): ";
cin >> depth;
cout << endl;
if (depth == 0) {
result = area (length, width);
cout << "With a length of " << length;
cout << " and a width of " << width;
cout << " the area is " << result << endl;
} else {
result = volume (length, width, depth);
cout << "With a length of " << length;
cout << " a width of " << width;
cout << " and a depth of " << depth;
cout << " the volume is " << result << endl;
} // end if
} // end loop
return 0;
} // end main function
int area (int l, int w) {
int result;
result=area(l,w);
return result;
} // end area function
int volume (int l, int w, int d) {
int result;
result=volume(l,w,d);
return result;
} // end volume function
Thank you,
bmgee13