+ 1
How to use the output result for a different operation
I made a simple code truly random numbers. How do I use the result for another if statement? https://code.sololearn.com/c0Us16zB0tL5/?ref=app
4 Answers
0
I don't know if I am properly understanding your problem...
But you could save that randomly generated number in a variable like this:
int myRandom = 1 +(rand () % 5);
So you would be able to use that random number later.
0
I used your solution, but the "if" statement is comparing only the first number from top to bottom. Is it recognizing all the numbers? And if it is how do I use the second and third number in the evaluation.
0
I think what you are trying to do is the following:
for (int x = 1; x <= 3; x++){
int myRandom = (rand () % 5);
cout << 1 + myRandom << endl;
if (myRandom > 3){
cout << "I rule\n";
}
if (myRandom < 3){
cout <<"you rule\n";
}
}
give it a try
0
Ok thanks for the help, now I am comparing the positions in the array, but it's confusing the coat lines of text. That are associated with the numbers.đ