been a while since I've done any C programming but from what I can see, the value stored in youtotal is not the number displayed.
| CODE | for (int i=1; i<=numcard; i++) cout<<random(10);
|
here you generate the numbers for the cards, which are shown to the user, but the values aren't actually stored anywhere.
the next line
stores a different random number for the user total.
What you want to do is create another integer variable to store the random number in. Within the for loop you want to store the random number in that new variable, display the variable, then add it to youtotal.
For Example:
| CODE | // Variables int numcard = 0; int youtotal = 0; int comptotal = 0; int cardvalue = 0;
|
(it's a good idea to set your variables to 0 or null when you declare them, particularly in C\C++)
and then further down where you calculate the card values
| CODE | for (int i=1; i<=numcard; i++) { cardvalue = random(10); cout << cardvalue; youtotal = youtotal + cardvalue; }
|
|