Question
I have the following C++ code of a horse race that I have put together. Can you go through and fill out appropriate comments throughout
I have the following C++ code of a horse race that I have put together. Can you go through and fill out appropriate comments throughout code ? For some reason I am not good with doing comments while I am coding.
#include
using namespace std;
int locate[5]={0};
void print(int horse) { for(int count=0; count<15; count++) { if(count==locate[horse]) cout << horse; else cout << "."; } cout << " "; }
int main() {
int seed=0, end=0; int declareWinner;
cout << "Please enter a random seed: "; cin >> seed; srand(seed);
while(1) { for(int add=0; add<5; add++) { locate[add] += (rand() %2); print(add); if(locate[add]==15) { end = 1; declareWinner = add; } } cout<< " "; if(end==1) break; }
cout << "Horse "<
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started