Please help me with this peice of code

Pages: 12
how would i use esle if in this code, can you give me an example,

and where is the sticky?
closed account (o3hC5Di1)
Hi there,

That's some progress already, well done.

As for your program shutting down, do the following:

1
2
3
4
5
6
7
8
int main()
{
    do 
    {
         //your code here   
    } while (1);
    return 0;
}


For more information on this, the sticky is the 2nd topic in the list on the first page of the "beginners forum".

Now, your code is basically doing something like this:

1
2
if x = 1 and y = 4   then print "stand"
if x = 1 then print "hold" 


Both of these conditions are true, so both "stand" and "print" will be printed.

If/else if/else solves this like so:

1
2
3
if x=1 and y=4   then print "stand"
else if x = 4 then print "hold"
else print "game over"


This is like saying:

- first check if x is 1 and y=4, if so print stand
- if that is not the case, check if x is 1, without y having to be 4, if so print hold
- if none of the above is true, print game over

This is quite basic stuff, please refer to http://cplusplus.com/doc/tutorial/control/ for more information.

Hope that helps.

All the best,
NwN
Last edited on
Reader,

Now the problem of my dealers cards all being the same was an easy problem to fix by changing the programming, however, my Y's appear around 10 times each throughout the code, can I still use else if on all these conditions?

-rebel1999
I answered you other thread to show how you might be able to fix the code.

http://www.cplusplus.com/forum/beginner/73219/
Topic archived. No new replies allowed.
Pages: 12