It's not bad. I have a few minor quips with it, however.
Specifically,
1. system("PAUSE") -- please don't use system():
http://cplusplus.com/forum/articles/11153/
2. system("CLS") -- see above, and also see:
http://cplusplus.com/forum/articles/10515/
3. Your indentation is a little inconsistent.
4.
using namespace std;
-- I know a lot of tutorials (including the one here, sadly) give the impression that it's good, I strongly recommend you don't use it. Some people here will agree with me and others won't; but personally I don't think it should ever be used. By all means, use
using
; but reserve it for separate symbols, as in
using std::cout
. Personally I don't think that the
using
directive should ever be used, but the C++ committee in its infinite wisdom decided to include it.
That's all really. The first problem is easy to fix. Instead of system("PAUSE") we can use the C++ iostream library.
This:
std::cin.get();
will make the program block until the ENTER key is pressed:
1 2
|
std::cout << "Press ENTER to continue...\n";
std::cin.get();
|
or better yet,
1 2
|
std::cout << "Press ENTER to continue...\n";
std::cin.ignore(std::numeric_limits<std::streamsize>::max(), '\n');
|
(Note: You will need to include <limits> to use the last one).
As for the system("CLS"); Duoas provides examples for that.