Hint

What is wrong with this code???

#include <iostream>
#include <ctime>
using namespace std;
void Chimera();
void LionBite();
void GoatHorns();
void SnakeTailBite();
void DragonBreath();
unsigned short input;

int main()
{
srand(time(NULL));
unsigned short Anum, Bnum, Cnum, Dnum;
Anum = rand() % 25 + 1;
Bnum= rand() % 55 + 1;
Cnum= rand() % 80 + 1;
Dnum= rand() % 100 + 1;
cout << "Please enter the number of times you want the Chimera to attack" << endl;
cin >> input;


for (unsigned short i = 0; i <= Anum; i++)
{
cout << "The lion head bites you!" << endl;
}

for (unsigned short i = 0; i <= Bnum; i++)
{
cout << "The goat head gores you with its horns!" << endl;
}
for (unsigned short i = 0; i <= Cnum; i++)
{
cout << "The snake head on the end of the tail bites you with poisonous fangs!" << endl;
}
for(unsigned short i = 0; i <= Dnum; i++)
{
cout << "The dragon head breaths fire on you!" << endl;
}
return 0;
Chimera();
LionBite();
GoatHorns();
SnakeTailBite();
DragonBreath();

}

void Chimera()
{
cout << "Please enter the number of times you want the Chimera to attack" << endl;
return;
}

void LionBite()
{
cout << "The lion head bites you!" << endl;
return;
}
void GoatHorns()
{
cout << "The goat head gores you with its horns!" << endl;
return;
}
void SnakeTailBite()
{
cout << "The snake head on the end of the tail bites you with poisonous fangs!" << endl;
return;
}
void DragonBreath()
{
cout << "The dragon head breaths fire on you!" << endl;
return;
}
Please use code tags. http://www.cplusplus.com/articles/jEywvCM9/
1
2
3
4
5
for (unsigned short i = 0; i <= Anum; i++)
{
    cout << "The lion head bites you!" << endl;
    LionBite();
}


1
2
3
4
cout << "Please enter the number of times you want the Chimera to attack" << endl;
cin >> input;

for (unsigned short i = 0; i <= Anum; i++)

input is completely independent of the number of times any beast attacks.

1
2
3
4
5
6
return 0;
Chimera();
LionBite();
GoatHorns();
SnakeTailBite();
DragonBreath();

Returning in main ends the program, so these functions never get called.
Last edited on
Thank you very much but the main problem is that i just want one for loop and create all that inside Chimera function... I am sorry I am just a beginner..
I have got this and now I don't know what to do.. I am very confused!!

#include <iostream>
#include <ctime>
using namespace std;
void Chimera();
void LionBite();
void GoatHorns();
void SnakeTailBite();
void DragonBreath();
unsigned short input;

int main()
{



cout << "Please enter the number of times you want the Chimera to attack" << endl;
cin >> input;



Chimera();
{
srand(time(NULL));
unsigned short Anum, Bnum, Cnum, Dnum;
Anum = rand() % 25 + 1;
Bnum = rand() % 55 + 1;
Cnum = rand() % 80 + 1;
Dnum = rand() % 100 + 1;
for (unsigned short i = 0; i <= Anum|| Bnum || Cnum || Dnum; i++)
{
LionBite();

GoatHorns();

SnakeTailBite();

DragonBreath();
}

}
LionBite();
GoatHorns();
SnakeTailBite();
DragonBreath();

}

void Chimera()
{
cout << "Please enter the number of times you want the Chimera to attack" << endl;
return;
}

void LionBite()
{
cout << "The lion head bites you!" << endl;
return;
}
void GoatHorns()
{
cout << "The goat head gores you with its horns!" << endl;
return;
}
void SnakeTailBite()
{
cout << "The snake head on the end of the tail bites you with poisonous fangs!" << endl;
return;
}
void DragonBreath()
{
cout << "The dragon head breaths fire on you!" << endl;
return;
}
for (unsigned short i = 0; i <= Anum|| Bnum || Cnum || Dnum; i++) should be this:

for (unsigned short i = 0; (i <= Anum) || (i <= Bnum) || (i <= Cnum) || (i <= Dnum); i++)
Last edited on
Topic archived. No new replies allowed.