Starting from:
$35

$29

Project [5]: Arrays Solution


Project Goals

The goals of this project are to:

    1. Get students familiar with the usage of 1D arrays

    2. Get students familiar with the usage of 2D arrays


Important Notes:

    1. Formatting: Make sure that you follow the precise recommendations for the output content and

formatting: for example do not change the text in the first problem from “Enter the size of the

array: ” to “Enter array size: ”. Your assignment will auto-graded and any changes in formatting will result in a loss in the grade.

    2. Comments: Header comments are required on all files and recommended for the rest of the program. Points will be deducted if no header comments are included.

    3. Restriction: The use of goto statements anywhere within this program is prohibited. Points will be deducted if goto is used.


Problem 1

Write a program that asks the user to enter an NxM dimensional array containing single digit values (only the digits between 0 and 9) and counts the number of times each one of the 10 digits appears in the array. This program should:

    • Prompt the user to enter the sizes (number of rows and number of columns) of the array, and read in the dimensions given by the user

    • Prompt the user to enter the array row-by-row and read in each value (separated by spaces)

    • Display the total number of times each digit appears in the array

    • Display the 1D array containing the counts of each digit in one line

    • Display the 2D array that the user entered

The program should function as follows (items underlined are to be entered by the user):


This program counts occurrences of digits 0 through 9 in an NxM array.

Enter the size of the array (Row Column): 2 6

Enter row 0: 0 1 2 3 4 5

Enter row 1: 0 1 6 7 8 9

Total counts for each digit:

Digit 0 occurs 2 times

Digit 1 occurs 2 times

Digit 2 occurs 1 times

Digit 3 occurs 1 times

Digit 4 occurs 1 times
Digit 5 occurs 1 times

Digit 6 occurs 1 times

Digit 7 occurs 1 times

Digit 8 occurs 1 times

Digit 9 occurs 1 times

The digit counts directly from the 1D array:

2211111111

The original 2D array entered by the user:

012345

016789



Note:

    • The counts for each digit must be stored in a single 1D array and cannot be stored in 10 different separate variables.


Save your program as arrays.c

Grading Rubric

Grading will be done for each problem as follows:

Correctly-named file
5%


Header comment
2%


Program compiles
5%


Correctly-reading data from terminal
28%


Correct result printed
60%





Submission details

To submit your project, you will have to save your project files to the NoMachine client:

    • Create a directory called “project5”

    • Save your *.c files in that directory

    • To submit: (don’t type the ‘>’ symbols)

        ◦ cd project5

        ◦ submit

The submission script copies all files in the current directory to our directory. You may submit as many times as you like before the deadline, we only keep the last submission.



Academic Honesty

Academic dishonesty is against university as well as the system community standards. Academic dishonesty includes, but is not limited to, the following:

Plagiarism: defined as submitting the language, ideas, thoughts or work of another as one's own; or assisting in the act of plagiarism by allowing one's work to be used in this fashion.

Cheating: defined as (1) obtaining or providing unauthorized information during an examination through verbal, visual or unauthorized use of books, notes, text and other materials; (2) obtaining or providing information concerning all or part of an examination prior to that examination; (3) taking an examination for another student, or arranging for another person to take an exam in one's place; (4) altering or changing test answers after submittal for grading, grades after grades have been awarded, or other academic records once these are official.

Cheating, plagiarism or otherwise obtaining grades under false pretenses” constitute academic dishonesty according to the code of this university. Academic dishonesty will not be tolerated and penalties can include cancelling a student’s enrolment without a grade, giving an F for the course, or for the assignment. For more details, see the University of Nevada, Reno General Catalog.

More products