Need code for problem

I was assigned a problem in class that we have to write a program for. The teacher didnt explain how to solve problems yet and barley just showed us what cout does. ed.


Last edited on
Please take a look:

http://www.cplusplus.com/forum/beginner/48696/


Hope this helps.
I looked at the link but don't understand what it has to do with this. I've never done C++ and this is only 2nd week of class. I'm not good with terms yet.
Fifth section http://www.cplusplus.com/forum/beginner/1/#msg6680

If you post the code you've written we can review it and help you understand what's wrong. If you can't do that your best option is to get a book and study, possibly asking the teacher if he can help you.
Last edited on
Look how I calculated, many years ago, the volume of a box:

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
//Write a program to find volume of a box

#include <iostream>

using namespace std;

int main ()
{
	int volume, l, b, h;
	
	cout << "Enter Length, Breadth and Height: ";
	
	cin >> l >> b >> h;
	
	volume = l * b * h;
	
	cout <<"Volume is: "<< volume << endl;
	
	getch ();
}


...hope this helps.
That makes sense to me. Now why do you need the int volume, l,b,h; in your code?


BTW this wasn't a hw problem but a test question I got stuck on
why do you need the int volume, l,b,h; in your code?


See Declaration of variables on this page:
http://www.cplusplus.com/doc/tutorial/variables/

If these sorts of questions give difficulty, you need to study the topic, either by working through the tutorial from the start, or by working from whichever textbooks or teaching material is recommended for your course.
got it. I figured it out. Just needed clarification on some stuff
Topic archived. No new replies allowed.