So, I made a coin flipping tool in C++, but the console always returns either every coin as Heads or every coin as Tails. Here's the code:
#include <cstdlib>
#include <ctime>
#include <iostream>
#include <string>
using namespace std;
int main() {
srand(time(nullptr));
int FLIP_RESULT = rand() % 2 + 1;
int NUMBER_OF_FLIPS = 0;
cout << "Welcome to Coin Flipper. How many coins would you like to flip?"
<< endl;
cin >> NUMBER_OF_FLIPS;
for (int COUNTER = 0; COUNTER < NUMBER_OF_FLIPS; COUNTER++) {
if (FLIP_RESULT == 1) {
cout << "Heads." << endl;
} else if (FLIP_RESULT == 2) {
cout << "Tails." << endl;
} else {
cout << "Error." << endl;
}
}
return 0;
}
What's going on?