QuestionQuestion

Create a program which will apply an addition operation of a user provided value to every cell of a two-dimensional array.
You must write your program in C. No memory leaks are allowed.
Create a two-dimensional array of integers which is randomly populated with values between 1 and 50. Establish the height and width of the area based on user input. Error handle this value to make sure it is a valid number greater than or equal to zero and no larger than 10. Print the array. Ask the user what value they would like to add to the array. Error handle this value to make sure it is a valid number greater than or equal to zero. Add this number to each element of the array. Print the array. End the program and make sure all memory has been freed. Make sure your program is decomposed into appropriate functions which could be reused on other data structures.
Remember to compile with gcc.

Solution PreviewSolution Preview

These solutions may offer step-by-step problem-solving explanations or good writing examples that include modern styles of formatting and construction of bibliographies out of text citations and references. Students may use these solutions for personal skill-building and practice. Unethical use is strictly forbidden.

#include <stdio.h>
#include <stdlib.h>
#include <limits.h>

// function prototype
int getUserInput(int min, int max, char message[]);

int ** allocateArray(int width, int height);
void printArray(int width, int height, int ** array);
void addToArray(int value, int width, int height, int ** array);

void freeArray(int height, int ** array);

int main(int argc, char** argv) {

// Establish the height and width of the area based on user input. Error handle this value to make sure it is a valid number greater than or equal to zero and no larger than 10.
    printf("Get height:\n");
    int height = getUserInput(0, 10, "Enter a valid number greater than or equal to zero and no larger than 10");
    printf("Get width:\n");
    int width = getUserInput(0, 10, "Enter a valid number greater than or equal to zero and no larger than 10");

// Create a two-dimensional array of integers which is randomly populated with values between 1 and 50.
    int ** array = allocateArray(width, height);...

By purchasing this solution you'll be able to access the following files:
Solution.c.

$68.00
for this solution

or FREE if you
register a new account!

PayPal, G Pay, ApplePay, Amazon Pay, and all major credit cards accepted.

Find A Tutor

View available C-Family Programming Tutors

Get College Homework Help.

Are you sure you don't want to upload any files?

Fast tutor response requires as much info as possible.

Decision:
Upload a file
Continue without uploading

SUBMIT YOUR HOMEWORK
We couldn't find that subject.
Please select the best match from the list below.

We'll send you an email right away. If it's not in your inbox, check your spam folder.

  • 1
  • 2
  • 3
Live Chats