HELP PLEASE

How could this be work??

if (boo=="rat");
{
SlowPrint("The Rat Tells: ", 25);
Sleep(500);
cout << rat;
}
if (boo=="horse");
{
SlowPrint("The Horse Tells: ", 25);
Sleep(500);
cout << horse;
}
if (boo=="rabbit");
{
SlowPrint("The Rabbit Tells: ", 25);
Sleep(500);
cout << rabbit;
}
if (boo=="dragon");
{
SlowPrint("The Dragon Tells: ", 25);
Sleep(500);
cout << dragon;
}
if (boo=="dog");
{
SlowPrint("The Dog Tells: ", 25);
Sleep(500);
cout << dog;
}
if (boo=="tiger");
{
SlowPrint("The Tiger Tells: ", 25);
Sleep(500);
cout << tiger;
}
if (boo=="snake");
{
SlowPrint("The Snake Tells: ", 25);
Sleep(500);
cout << snake;
}
if (boo=="ox");
{
SlowPrint("The Ox Tells: ", 25);
Sleep(500);
cout << ox;
}
if (boo=="rooster");
{
SlowPrint("The Rooster Tells: ", 25);
Sleep(500);
cout << rooster;
}
if (boo=="pig");
{
SlowPrint("The Pig Tells: ", 25);
Sleep(500);
cout << pig;
}
if (boo=="sheep");
{
SlowPrint("The Sheep Tells: ", 25);
Sleep(500);
cout << sheep;
}
if (boo=="monkey");
{
SlowPrint("The Monkey Tells: ", 25);
Sleep(500);
cout << monkey;
}
Why not?
Last edited on
It doesn't work.

1
2
3
4
5
6
7
8
9
10
11
12
13
if (boo=="rat");
{
    SlowPrint("The Rat Tells: ", 25);
    Sleep(500);
    cout << rat;
}

if (boo=="horse");
{
    SlowPrint("The Horse Tells: ", 25);
    Sleep(500);
    cout << horse;
}

Notice the semicolon at lines 1 and 8 above

The semicolon ends the "if" statement so you have this:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
if (boo=="rat")
    ;

{
    SlowPrint("The Rat Tells: ", 25);
    Sleep(500);
    cout << rat;
}

if (boo=="horse")
    ;

{
    SlowPrint("The Horse Tells: ", 25);
    Sleep(500);
    cout << horse;
}

Above, as you see, each "if" statement controls nothing.


It could be corrected like this:
1
2
3
4
5
6
7
8
9
10
11
12
13
if (boo=="rat")
{
    SlowPrint("The Rat Tells: ", 25);
    Sleep(500);
    cout << rat;
}

if (boo=="horse")
{
    SlowPrint("The Horse Tells: ", 25);
    Sleep(500);
    cout << horse;
}


or you could also use else followed by if, like this:
1
2
3
4
5
6
7
8
9
10
11
12
if (boo=="rat")
{
    SlowPrint("The Rat Tells: ", 25);
    Sleep(500);
    cout << rat;
}
else if (boo=="horse")
{
    SlowPrint("The Horse Tells: ", 25);
    Sleep(500);
    cout << horse;
}
Topic archived. No new replies allowed.