| Hazique35 (88) | |
|
Anyone can help? I typed this code into a WIN32 Console application. Some things that I wanted to be displayed were not displayed. the only thing that comes up is 'GAME OVER'. I tried to fix this one but could not. I have comments running down the code to let you know what I wanted to happen. Thank you in advance! (I have made my comments in bold) #include <iostream> #include <string> using namespace std; using std::cout; using std::endl; using std::cin; using std::string; int score, total; char lives, deaths; int main() { cout << "GAME OVER"; //Here i want GAME OVER to come up cout << "ENTER YOUR SCORE:"; //Here i want ENTER YOUR SCORE to come up cin >> score; //Here i want to be able to type an integer value next to ENTER YOUR SCORE cout << "ENTER YOUR LIVES:"; //Here i want ENTER YOUR LIVES to come up cin >> lives; //Here i want to be able to type in a one-value next to ENTER YOUR LIVES cout << "ENTER YOUR DEATHS:"; //Here i want ENTER YOUR DEATHS to come up cin >> deaths; //Here i want to be able to type in a one-value integer next to ENTER YOUR DEATHS total = (score * lives) / (deaths * 10); //Here I want to be able to calculate the score cout << "YOUR TOTAL SCORE:" << total; //Here I want YOUR TOTAL SCORE to come up system ("pause"); return 0; } | |
|
|
|
| Zereo (181) | |||||
|
First be sure to use code tags when posting your code (The <> symbol on the right when replying and bottom when posting) it makes your code alot easier to read. Now your problem is you are trying to * a char type and a int type. Try changing lives and deaths to type int. Also you dont need to have
since you have using namespace std; which is basically saying to look in the standard libary for things like endl; string; ect.also change your game over code, and the cout under total so it looks like this. Which makes a newline.
Also using global variables is very dangerous unless they are needed. You should move all your variables in this program in the main block since that is the only part of the program that uses them. | |||||
|
Last edited on
|
|||||
| Hazique35 (88) | |
| thanks. | |
|
|
|