I am writing a program to simulate a plinko board, and as part of this program I have a function that displays the money assigned to each slot. I am trying to use std :: fixed and std :: setprecision to output each value with two zeros after the decimal point, but each value is output as if I did not use fixed at all. What am I missing? Here is my code:
#include <iostream>
#include <iomanip>
using namespace std;
void ChipsAllSlots(int numChips) {
const int NUM_SLOTS = 9;
const int slotWinnings[NUM_SLOTS] = {100, 500, 1000, 0, 10000, 0, 1000, 500, 100};
for (int i = 0; i < numChips; ++i) {
cout << fixed << setprecision(2) << slotWinnings[i] << endl;
}
}
int main() {
ChipsAllSlots(9);
return 0;
}
source
share