// Computer guess the number
// Input a number and the comp will try and guess it
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
int main()
{
cout << "\tWelcome to Computer Guess My Number\n\n";
do
{
int number1;
cout << "Enter your number: ";
cin >> number1;
srand(time(0)); // seed random number generator
int theNumber = rand() % 100 + 1; // random number between 1 and 100
int tries = 0, guess;
cout << "Computer guessed: " << theNumber;
}
while();system("pause")
;return 0;
}
Error: expected primary-expression before ')' tokenBeggining of a code
Page 1 of 1
6 Replies - 10180 Views - Last Post: 29 January 2009 - 09:06 PM
#1
Error: expected primary-expression before ')' token
Posted 29 January 2009 - 06:31 PM
I made a code where the computer thinks of a random number between 1 and 100. Now i am trying to make a code where i input a number and the computer tries to guess it. this is only the beginning of the code so i have two questions. First and foremost is this how i would start off this kind of program and question number 2, when i try to compile it the compiler says " line 26 - expected primary-expression before ')' token" whats wrong with it? what is a primary expression. Im new at this programming language. line 26 is the line that says "while();system("pause")" here's the code:
Replies To: Error: expected primary-expression before ')' token
#2
Re: Error: expected primary-expression before ')' token
Posted 29 January 2009 - 06:37 PM
Any help would be greatly appreciated.
#3
Re: Error: expected primary-expression before ')' token
Posted 29 January 2009 - 06:48 PM
Anyone?
#4
Re: Error: expected primary-expression before ')' token
Posted 29 January 2009 - 06:50 PM
Don't bump your threads, it will generally just make it take longer to get a reply as those who waited the longest get helped first and they're further down the list.
while();system("pause")
A while statements need some argument to evaluate to either true or false.
Just exchange the entire line for
cin >> number1;
it will promt the user for some input and then you just ignore the input.
while();system("pause")
A while statements need some argument to evaluate to either true or false.
Just exchange the entire line for
cin >> number1;
it will promt the user for some input and then you just ignore the input.
#5
Re: Error: expected primary-expression before ')' token
Posted 29 January 2009 - 06:52 PM
thanks!
#6
Re: Error: expected primary-expression before ')' token
Posted 29 January 2009 - 06:54 PM
no problemo!
#7
Re: Error: expected primary-expression before ')' token
Posted 29 January 2009 - 09:06 PM
Modified title to be more descriptive of the problem.
Page 1 of 1
|
|

New Topic/Question
Reply




MultiQuote





|