Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

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 #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

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

101 Database Exercises Text Workbook

Authors: McGraw-Hill

2nd Edition

0028007484, 978-0028007489

More Books

Students also viewed these Databases questions

Question

To solve by the graphical methods 2x +3y = 9 9x - 8y = 10

Answered: 1 week ago

Question

Why does sin 2x + cos2x =1 ?

Answered: 1 week ago

Question

What are DNA and RNA and what is the difference between them?

Answered: 1 week ago

Question

Why do living creatures die? Can it be proved that they are reborn?

Answered: 1 week ago