GAME

Hello guys,
Actually my game is like the user has to enter some number(between 1&3) and the computer will also randomize some number.
If the number entered by both of them is the same then the computer says"you lose else the loop should continue.
Also if the score of any of them is greater than 5 then the game should finish.
I wanted to count the scores of these two seperately and display it at the end of the match.
[b][b](Please using count++)
PLEASE CHECK MY PROGRAM AND DO THE REQUIRED MODIFICATIONS (according to the rules)
[CHECK THE PROGRAM ACCORDING TO TUBO C++ BORLAND]
[/b][/b]
#include<iostream.h>
#include<time.h>
#include<stdio.h>
#include<stdlib.h>
#include<iomanip.h>
int main()
{
int a;
for(int i=0;i<10;i++)
{randomize();
srand=time(0);
int s=rand()%3+1;
cout<<"Enter any number";
cin>>a;
cout<<"The number of the computer is "<<setw(16)<<s;
if(a||s>5)
cout<<//the score that has been counted"
//also
if(a==s)
cout<<"You lose";
getchar();
return 0;
}
[b][b][b][b][b]I NEED THIS QUICKLY BECAUSE I HAVE TO SUBMIT IT DAY AFTER TOMORROW. [/b][/b][/b][/b][/b]
I'm guessing the problem is here:
if(a||s>5)
That's not what you mean. It will always return false. What you wanted is probably this:
if (a > 5 || s > 5)
...which is a bit silly, because s can never be > 5 since it is initialized as [1, 3] and never changed.

Also, you seem to be missing a '}' somewhere, but I honestly don't know what you're trying to do so I can't tell you where.
I'd also like to point out that its against the rules to post your homework here, and ask people to correct it and give you. Also, relax and calm own a bit, day after tomorrow is a long time.. So tone down with the attempt on extra bold and the caps... Its irritating...

Secondly, to help you out, just think out first, how many minimum variables do you need?
1) The user's number,
2) The computer's number,
3) Number of user wins,
4) Number of computer wins,
You have written a program just with 2 how do you expect it to work...

Also, how does this even compile? Like Gaminic said, you have a } missing... there is a ; missing on one of the lines (but since you haven't bothered to use code tags, I can't point out where...

As far as my knowledge goes, I haven't heard of the "randomize()" function...

Since you want the game to go on till one of the scores is not 5, you need a do-while loop...

Try correcting your problems, and then maybe we can help you out more, but no one here is going to give you the program just like that... And as a suggestion, use indentation... Makes the code more readable, and easier for us to read. And enclose your program in code tags.. The option is to your right under the "Format: " option...

Hope this helps.. :)
Last edited on
Topic archived. No new replies allowed.