Hint please!!

How should I write this program if I have to write it with "for loop" instead of "if"...

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

int main()
{
srand(static_cast<unsigned int> (time(0)));
unsigned short input;
cout << "Please enter the number of times you want the Chimera to attack" << endl;
cin >> input;

while (input < 101)
{
if (input <= 25 )
{
cout <<"The lion head bites you!" << endl;
}
else
{
if(input <= 50 && input > 25)
{
cout << "The goat head gores you with its horns!" << endl;
}
}
if (input <= 80 && input > 50)
{
cout << "The snake head on the end of the tail bites you with poisonous fangs!" << endl;
}
else
{
if (input <= 100 && input > 80)
{
cout << "The dragon head breaths fire on you!" << endl;
}
}


return 0;

}

Chimera();
LionBite();
GoatHorns();
SnakeTailBite();
DragonBreath();

return 0;

}

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;
}
closed account (48T7M4Gy)
http://www.cplusplus.com/doc/tutorial/control/
I actually have to convert it to "for loop" in a way that if I input 6 then it gives me 6 different random outputs but from the mentioned 'voids'. If that makes sense..
closed account (48T7M4Gy)
1
2
3
4
5
6
cin >> no_of_loops;

for(int i = 0; i < no_of_loops; i++)
{
   // generate a random output
}
Last edited on
Topic archived. No new replies allowed.