using namespace std;
int main()
{
unsigned seed = 0;
int randomNum;
int randomNum1;
int number;
int answer;
srand(time(0));
randomNum = 1 + rand() % 50;
randomNum1 = 1 + rand() % 50;
number = randomNum + randomNum1;
cout << "Key in a number for the Random Number seed" << endl;
cout << "and hit the Enter key to display an addition problem. ";
cin >> seed;
cout << setw (9) << randomNum << endl;
cout << "+";
cout << setw (8) << randomNum1 << endl;
cout << setw (9) << "----" << endl;
cin >> answer; // This is what I need to be coded right!
if (answer == number)
cout << "Congratulations! That's right." << endl;
else
cout << "Sorry, the correct answer is " << number << endl;
return 0;
}
The problem is that for the cin answer I want it to be like this format:
space 49
+space 10 //ignore the space the forum wont let me do it proper but basically line
----- all the numbers up even the cin answer
space ##
I tried to do
cin >> setw (9) >> answer; and also
cin >> right >> setw (1) >> answer;
and nothing happened basically my ? is how do I get the user to input his answer in the same lineup of the other 2 random numbers generated! any help would be GREATLY APPRECIATED LOL spent like 1-2 hours looking around the web for a case like this and NOTHING! >.<
No comments posted yet
Your Answer:
Login to answer
189
29
Other forums
socket makes browser hang...
I have a socket server, and I am having a problem at the moment...
A browser sends a http hea
get the country of visitor and display content based on that
Hello all,
I have seen that Google analytics can tell you where a visitor is coming from and
MySQL query problem
When I try to run the following piece of code, I get this error:
QuoteWarning: mysql_query(): sup
Fatal error: Call to a member function fetchrow() on a non-object in C:xamppht
okay i have this query and everytime i add `item_id`=? to it... it gives me the error in the title..
Execure stored procedure on a timer
Can someone tell me an easier way to execute a stored procedure on a timer? I am using Oracle 10g R
function to return url
Hi,
Can you guys help me giving a function that takes all the contents in a particular field
Multithreading design
Hi
I have come up with a Singleton class that manages a pool of database connections. Basical
how to configure ADS in ABAP instance
Hi All,
I am working on r/3 4.7 ABAP system.Can we configure ADS(adobe document services)
Storing user data help?
Hey Guys,
I'm not use if this question is to broad but I can always give you more informatio
newbie error
what is wrong with this code ?
<html>
<body>
<?