Docsity

Computer Science Quiz6, Quizzes of Computer Science

Toggle sidebar
bg1
CptS 121 – Program Design and Development
Date Assigned: Fri, Oct 10, 2025 Due Date: Mon, Oct 13, 2025
Take-Home Quiz 6 (15 pts) – Arrays
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>_quiz6.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.
NOTE: The use of gen AI is forbidden for quizzes.
1. (5 pts) In your own words, what is an
array
? Explain.
An array is a collection of elements of the same data type stored in contiguous
memory locations. Each element in the array can be accessed using an index,
where indexing starts at 0 in C. Arrays make it easy to store and process multiple
related values together (for example, test scores, characters in a word, or student
IDs). In short, an array helps organize data efficiently so it can be accessed and
manipulated using loops or functions.
2. (10 pts) Write a function called count_alphas() that accepts an
array of
characters
and the
number
of items in the array as
parameters, and returns the number of
alphabetic
characters
(lowercase and uppercase) in the array. For example, if the array
contains [‘C’, ‘p’, ‘t’, ‘S’, ‘1’, ‘2’, ‘1’], then the function returns 4.
Note: if the array does not contain any
alphabetic
characters,
then the function returns 0. You may use functions in <ctype.h>.
Hint: isalpha().
Instructor: Andrew S. O’Fallon
pf2

Partial preview of the text

Download Computer Science Quiz6 and more Quizzes Computer Science in PDF only on Docsity!

CptS 121 – Program Design and Development Date Assigned: Fri, Oct 10, 2025 Due Date: Mon, Oct 13, 2025 Take-Home Quiz 6 (15 pts) – Arrays 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 _quiz6.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. NOTE: The use of gen AI is forbidden for quizzes.

1. (5 pts) In your own words, what is an array? Explain.

An array is a collection of elements of the same data type stored in contiguous memory locations. Each element in the array can be accessed using an index, where indexing starts at 0 in C. Arrays make it easy to store and process multiple related values together (for example, test scores, characters in a word, or student IDs). In short, an array helps organize data efficiently so it can be accessed and manipulated using loops or functions.

  1. (10 pts) Write a function called count_alphas() that accepts an

array of characters and the number of items in the array as

parameters, and returns the number of alphabetic characters

(lowercase and uppercase) in the array. For example, if the array contains [‘C’, ‘p’, ‘t’, ‘S’, ‘1’, ‘2’, ‘1’], then the function returns 4.

Note: if the array does not contain any alphabetic characters,

then the function returns 0. You may use functions in <ctype.h>. Hint: isalpha(). Instructor: Andrew S. O’Fallon

CptS 121 – Program Design and Development Date Assigned: Fri, Oct 10, 2025 Due Date: Mon, Oct 13, 2025 Instructor: Andrew S. O’Fallon