0% found this document useful (0 votes)
19 views2 pages

Quiz7 Phelps

Uploaded by

acidreturn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views2 pages

Quiz7 Phelps

Uploaded by

acidreturn
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 2

CptS 121 – Program Design and Development

Date Assigned: Fri, Oct 18, 2024 Due Date: Mon, Oct 21, 2024

Your Name: ____Henry Phelps____________ TA’s Name: _____Colin Van Dyke________


ID#: ____11889828_______________ Section #: ___________19______________

Take-Home Quiz 7 (15 pts) – Arrays and Strings

Using Canvas https://canvas.wsu.edu/, please submit your solution to the correct quiz
folder. Your solution should be a .pdf file with the name <your last name>_quiz7.pdf
and uploaded. To upload your solution, please navigate to your correct Canvas lab
course space. Select the “Assignments” link in the main left menu bar. Navigate to the
correct quiz submission folder. Click the “Start Assignment” button. Click the “Upload
File” button. Choose the appropriate .pdf file with your solution. Finally, click the
“Submit Assignment” button.

1. (5 pts) Define and describe a C string.

A C string is an array of characters that ends with the null character (\


0). C strings can be defined as character arrays or using pointer
notation, as such: char string [] = “hello” or char* string = “hello”, the
double quotes are the special syntax for strings that tell the compiler
to put a null character at the end of the character array.

2. (10 pts) Write a function called reverse_matrix(), which


accepts as parameters: a two-dimensional array of integers, the
number of rows, and the number of columns in the array.
Assume that the number of columns cannot exceed 100. The
function iterates through each column and reverses the elements
as shown below. The function does not directly return a value.
For example, given the following 2D array:

6 1 7 4 2
7 5 2 3 8
9 9 1 1 5
1 2 3 4 5

The function will produce the following array:

1 2 3 4 5
9 9 1 1 5

Instructor: Andrew S. O’Fallon


CptS 121 – Program Design and Development
Date Assigned: Fri, Oct 18, 2024 Due Date: Mon, Oct 21, 2024

Your Name: ____Henry Phelps____________ TA’s Name: _____Colin Van Dyke________


ID#: ____11889828_______________ Section #: ___________19______________
7 5 2 3 8
6 1 7 4 2

Void reverse_matrix(int array[][], int rows, int columns)


{
int temp = 0;

for (int i = 0; i < rows; i++)


{
for (int j = 0; j < columns; j++)
{
temp = array[i][j];
array[i][j] = array[rows-(i+1)][j];
array[rows - i][j] = temp;
}
}
}

Instructor: Andrew S. O’Fallon

You might also like