Need some quick aid

Okay, so this is my first attempt at C++ and I made a volume calc.
I can't seem to find whats wrong with the code!

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
#include <iostream>
#include "string"
using namespace std;
int main()
{
	// Integers here
	int Width;
	int Length;
	int Height;
	cout<<"Please enter the value to find the volume in the following order : Width, Lenght and Height.";
	cin>> Width;
	cin>> Length;
	cin>> Height;

	while( Width<0 || Length<0 || Height<0 ){// restrictions here
		cout<<"The values must be greater than 0. Please re-enter the values."<<endl;
		cin>> Width;
		cout<< endl;
		cin>> Length;
		cout<< endl;
		cin>> Height;
		cout<< endl;
	}
	cout<< endl;
	cout<<"The answer is : "<<"Width * Length * Height"<< endl;
	

	return 0;
}


any help would be appreciated thanks!!
Last edited on
line 25 is outputting only text, not the value...
and how would i fix that?
Try to figure it out yourself, how can you say that something is text in C++?
hmmm

cout<<"The answer is = "<<endl<<"Width x Length x Height = "<< Width * Length * Height << endl;
You don't need string for this program.And when you compile your program leave out the remarks they just lay in your program uselessly.
Comments are a good thing, clover leaf. Go look at the help I offered you in your other thread..

Your compiler will ignore any comments in your code and therefore has no effect on the final executable. However those comments will serve to jog your memory when you return to some code you've written a long time ago and now can't remember what you were doing, as you discovered recently. Also if some poor unfortunate wreck has to maintain your code at some point after you're gone he will thank you for those comments.
Last edited on
Topic archived. No new replies allowed.