Question

In: Computer Science

Submit a well-commented C program.   Create code. That will build a random 8x8 2D array of...

Submit a well-commented C program.  

Create code.

That will build a random 8x8 2D array of small-case characters.

Demonstrate how it functions by printing out the result on your screen.

Add a function will print out a single line of the array. If the user enters a value between 0 and 7 to select to print out a single row of the original 2D array.   

            void printLine(char *,int);    // This is the prototype declaration

            void printLine(char myArr[][])     // This is the definition.

Note that L is the line to be printed.

Solutions

Expert Solution

#include <stdio.h>

#include <stdlib.h>

#include <time.h>

void printLine(char [][8],int);

int main(){

int n;

printf("Enter value:");

scanf("%d",&n);

srand(time(0));

char myArray[8][8];

for(int i=0;i<8;i++){

for(int j=0;j<8;j++){

myArray[i][j]=(rand() % (122 - 97 + 1)) + 97;

}

}

printLine(myArray,n);

return 0;

}

void printLine(char myArray[][8],int n){

if(n>=0 && n<=7){

for(int i=0;i<8;i++){

for(int j=0;j<8;j++){

printf("%c",myArray[i][j]);

}

}printf("\n");

}

}

The function prototype must be same as function defination otherise it gives error

so the prototype is

void printLine(char [][8],int);

then only the function definition will works


Related Solutions

In C, build a connect 4 game with no GUI. Use a 2D array as the...
In C, build a connect 4 game with no GUI. Use a 2D array as the Data structure. First, build the skeleton of the game. Then, build the game. Some guidelines include... SKELETON: Connect Four is a game that alternates player 1 and player 2. You should keep track of whose turn it is next. Create functions: Initialization – print “Setting up the game”. Ask each player their name. Teardown – print “Destroying the game” Accept Input – accept a...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with...
Develop a python program to - Create a 2D 10x10 numpy array and fill it with the random numbers between 1 and 9 (including 0 and 9). - Assume that you are located at (0,0) (upper-left corner) and want to move to (9,9) (lower-right corner) step by step. In each step, you can only move right or down in the array. - Develop a function to simulate random movement from (0,0) to (9,9) and return sum of all cell values...
(code in C++ language) [Code Bubble sort, Insertion sort Create a Big array with random numbers....
(code in C++ language) [Code Bubble sort, Insertion sort Create a Big array with random numbers. Record the time. Run Bubble Check time (compute the processing time) do it 100 times (random numbers) Take the average Insertion: Compare] (some explanations please)
please submit the C code( no third party library). the C code will create output to...
please submit the C code( no third party library). the C code will create output to a file, and iterate in a loop 60 times and each iteration is 1 second, and if any key from your keyboard is pressed will write a 1 in the file, for every second no key is pressed, will write a 0 into the output file.
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes...
1. (50 pts) Write a C program that generates a 2D array-of-double and finds the indexes of the largest value stored in the 2D array. Specific requirements: (1) Your main function defines the 2D array a. You will need to prompt the user to specify the size of the 2D array b. You will need to prompt the user to put in numbers to initialize the array (2) Write a function to display the array that is visualized as rows...
few problems example of array and 2d array and the solution code in java language. I...
few problems example of array and 2d array and the solution code in java language. I am new to java and trying to learn this chapter and it is kinda hard for me to understand.
Create a C++ program that makes use of both concepts i.e. Array of structure and array...
Create a C++ program that makes use of both concepts i.e. Array of structure and array within the structure by using the following guidelines: 1. Create an Array of 5 Structures of Student Records 2. Each structure must contain: a. An array of Full Name of Student b. Registration Number in proper Format i.e 18-SE-24 c. An array of Marks of 3 subjects d. Display that information of all students in Ascending order using “Name” e. Search a particular student...
can you please create the code program in PYTHON for me. i want to create array...
can you please create the code program in PYTHON for me. i want to create array matrix Nx1 (N is multiple of 4 and start from 16), and matrix has the value of elements like this: if N = 16, matrix is [ 4 4 4 4 -4 -4 -4 -4 4 4 4 4 -4 -4 -4 -4] if N = 64, matrix is [8 8 8 8 8 8 8 8 -8 -8 -8 -8 -8 -8 -8...
Need C++ code for following with a document describing the code as well: Write a program...
Need C++ code for following with a document describing the code as well: Write a program to implement the game of Tic Tac Toe Four. The game is played on a 4 × 4 chessboard, within 2 players. The player who is playing "X" always goes first. Players alternate placing Xs and Os on the board until either one player has four in a row, horizontally, vertically, or diagonally; or all 16 squares are filled(which is a draw). The program...
C# - count =0; - Create a 2d array "items". string[,] items = new string[100, 4];...
C# - count =0; - Create a 2d array "items". string[,] items = new string[100, 4]; - Create a do while loop, when the user enters "0", stop the loop. - Users enter the item name, price, quantity, save this info and subtotal to array. - increase "count++" -convert price(decimal, Convert.ToDecimal() ) and quantity(int) to do multiplication for subtotal - create a for loop (with count ) to cycle through the "items", display item name, price, quantity, and subtotal. accumulate...
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT