Hello, I'm completely new to this and this might be a stupid question, but when I start this without debugging and the command prompt appears, I was wondering if I can input the values for the length and width in the command prompt. If so how? Or is this not how things work and a stupid question?
1 2 3 4 5 6 7 8 9 10 11 12 13 14
#include <iostream>
using std::cin; using std::cout; using std::endl;
int main() {
cout << "Rectangle Dimensions ";
int length;
int width;
cin >> length >> width;
int area = length * width;
cout << "Area: " << area << " = length "
<< length << " * width " << width << endl;
}
If you are running in some crazy, bloated, ill-designed IDE where a temporary command window shuts as soon as the program finishes and before you've had time to read the result then read this sticky: http://www.cplusplus.com/forum/beginner/1988/#msg7262
There's probably some badly-advertised setting on your IDE that will achieve the same.
Better still, open a Windows command prompt from the Windows start menu, navigate to the folder with your program in, type the name of the program and the command window will stay open as long as you like. Then, when you find that the command prompt is actually quite a useful tool, create a link to it on your desktop and you can start launching editors, compiling and running programs from the command line as well.