Question: Please provide a C code . Please provide your own code. DO NOT COPY answers from other locations. I posted it again because there are
Please provide a C code . Please provide your own code. DO NOT COPY answers from other locations. I posted it again because there are different requirments here and the other provided answers are wrong.
Purpose of Program
The purpose of the program is to populate a 2-d array of C-strings (3-d array of chars) that will be used for a classroom seating chart, print out all the strings entered in a table, and then calculate some values related to the 2-d array of c-strings.
main()
In main(), allow the user to enter in the number of rows first, and then number of columns, that the seating chart will have. Include a check that the number of rows AND number of columns requested is not too large, such that a 10x10 array of C-strings is sufficient. Do this by looping until positive values less than 10 are entered.
Finally, the rest of main() should include calls to the user-defined functions described below and display any results from the three functions in the appropriate manner.
Note: The 3d char array, ourRoom[][][], and any other information MUST be passed to the functions. No global variables should be used.
readNames()
The first function, readNames(), should populate the 2d array of C-strings from a list of user inputted names. The function has parameters for the number of rows and number of columns in the seating chart. The function should read-in strings (including whitespace), storing them in columns first. [NOTE: if you use fgets(), make sure to call fflush(stdin) immediately before to flush the stream of old newline characters.]
printChart()
The next function, printChart(), prints the 2d array of C-strings nicely as a table, making sure columns line up. Each row on the screen should correspond to each row in the seating chart.
thirdFunction()
The third function should return the number of names in the entire chart that are less than than the parameter length AND create a 1-d array that holds the average length of the names per row (a 1-d array of doubles). The length parameter should be requested to be entered by the user in main() and then passed to the function as an argument. The results from the function should then be displayed by main().
Sample Output
When the input is as follows:
20 25 2 20 25 3 mark smith anna hampton brad johnson barb hughes raj patel sema tara 10
the output should include the seating chart:
mark smith brad johnson raj patel anna hampton barb hughes sema tara
AND the thirdFunction() should output:
The number of names in ourRoom that are less than length 10 is 2. The average length of name for row 0 is 10.33. The average length of name for row 1 is 10.67.
Given
#include #include #include #include
void readNames(char myChart[10][10][15], int numRows, int numCols) { // place code for readNames here }
void printChart(char myChart[10][10][15], int numRows, int numCols) { // place code for printChart here }
int thirdFunction(char myChart[10][10][15], int numRows, int numCols, int length, double values[10]) { // place code for thirdFunction here }
int main() { char ourRoom[10][10][15]; // largest chart we will need double results[10]; // for thirdFunction results
// place code here for your header
// place code here for reading in number rows, number columns, and // code that makes sure the rows and columns are always less than 10 and // also code that calls your three functions appropriately
return 0; }
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
