Step 1: Write a program with two functions: InitArray() and PrintArray() . The p
ID: 3865027 • Letter: S
Question
Step 1: Write a program with two functions: InitArray() and PrintArray(). The program should create a 10 by 10 array of random integers (1 - 100) in InitArray() and display the array in PrintArray(). (No global variables.)
Step 2: Create a bool function FindNumber() that accepts a number and returns its first location in the array.
Step 3: Add logic so that the user can guess a number and have the program return a message stating higher/lower for the x and y coordinates until they guess the number.
Bonus Step: Modify InitArray() so that no numbers are duplicated and change the logic so that the computer chooses the number and the user guesses the location.
Explanation / Answer
#include <iostream>
#include <cstdlib>
#include <ctime>
using namespace std;
void initarray()
{
int array[10][10];
for(int i=0; i<10; i++){
for(int j=0;j<10;j++)
{
array[i][j] = (rand()%100)+1;
cout << array[i][j] << endl;
}
}
}
int main()
{
cout << "Hello World" << endl;
initarray();
return 0;
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.