Write a for loop to populate array userGusses with NUMGUESSE

Write a for loop to populate array userGusses with NUM_GUESSES integers. Read integers using scanf. Ex: if NUM_GUESSES is 3 and user enters 9 5 2, then userGusses is {9, 5, 2} #include int main(void) {const int NUM_GUESSES = 3; int userGuesses[NUM_GUESSES]; int i = 0; for (i = 0; i

Solution

The required student code is;

for (i=0;i<NUM_GUESSES;i++)

{

Cin>>userGuesses[i];

Or

In the given solution box:

Printf (‘’enter %d guesses:   ‘’,NUM_GUESSES);

//read the guess by using scanf

For(i=o;i< NUM_GUESSES;i++)

{

Scanf(‘’%d’’,&userGuesses[i]);

}

/*print that guesses*/

Printf(‘’userGuesses is ‘’)

Printf(‘’ {‘’);

For(i=o;i< NUM_GUESSES;i++)

{

Printf(‘’%d’’,userGuesses is[i] ‘’)

If(i<NUM_GUESSES-1)

Printf(‘’ ,‘’);

}

Printf(‘’} \ ’’);

Return 0;}

 Write a for loop to populate array userGusses with NUM_GUESSES integers. Read integers using scanf. Ex: if NUM_GUESSES is 3 and user enters 9 5 2, then userGus

Get Help Now

Submit a Take Down Notice

Tutor
Tutor: Dr Jack
Most rated tutor on our site