• Wrong document? Swap it for free
  • Written by students who passed
  • Immediately available after payment
  • Read online or as PDF
Sell
Where do you study
Your language
Document preview thumbnail
Preview 2 out of 7 pages
Exam (elaborations)

CPSC 1010 Exam 2 Review: Arrays, Array Initialization, String Handling, strlen, strcat, strcmp, Character Arrays, Integer Arrays, Loops, printf Output, Function Calls, Scope, Local vs Global Variables, Passing Arrays to Functions, Return Values, Function

Document preview thumbnail
Preview 2 out of 7 pages

CPSC 1010 Exam 2 Review: Arrays, Array Initialization, String Handling, strlen, strcat, strcmp, Character Arrays, Integer Arrays, Loops, printf Output, Function Calls, Scope, Local vs Global Variables, Passing Arrays to Functions, Return Values, Function Prototypes, Header Files, #include Directives, Makefile Compilation, Executable Naming, make Commands, Source File Management, String Concatenation, String Comparison, Null Terminator, Input/Output, Control Flow, Variable Tracing, Debugging, C Syntax, Pointers and Addresses, Array Indexing, Common Errors, Code Documentation, Modular Programming, Function Implementation vs Prototype Exam Questions Verified and Provided with A+ Graded Rationales Latest Updated 2026 Declare an array of 5 integers called array1 and initialize the array with the values 1-5. int array1[5] = {1, 2, 3, 4, 5}; Is this a valid array declaration? int array2[] = {1, 2, 3, 4, 5}; yes What would print to the screen with this code? int array3[5] = {1, 2, 3}; int i; for(i = 0; i 5; i++) printf("%d ", array3[i]); 1 2 3 0 0 What would print to the screen with this code? int array3[5] = {'1', '2', '3'}; int i; for(i = 0; i 5; i++) printf("%d ", array3[i]); How many characters are in this array? char word1[] = {"CS for all"}; 11 total Finish this code to find the length of the string: char word1[] = {"CS for all"}; int length; // use strlen function length = strlen(word1); What value will the printf print? char word1[] = {"CS for all"}; int length = strlen(word1); printf("length of word1 is: %dn" length); 10 How many characters are in this array? char word2[] = {'a', 'l', 'l', ' ', 'i', 'n'}; 6 total Write the code to combine the contents of the first three word arrays to produce the phrase "All in for Clemson" in the phrase array. char word3[] = {"All in "}; char word4[] = {'f', 'o', 'r', '0'}; char word5[] = " Clemson"; char phrase[30] = {'0'}; strcat(phrase, word3); strcat(phrase, word4); strcat(phrase, word5); - - If missing the null character at the end of word4, weird things happen; same with missing null character in phrase. Write the code to compare word6 and word7 and print out "Tigers" if they contain the same value. char word6[] = "Clemson"; char word7[] = "Clemson"; if (strcmp(word6, word7) == 0) printf("Tigersn"); - - . Cannot use if(word6 == word7) What is the first thing that will be printed to the screen? first var is 1 What is the second thing printed to the screen? here var is 10 What is the third thing printed to the screen then var is 17 What is the fourth thing printed to the screen? next var is 10 What is printed when f1() is called? f1: var is 25 on entering f1: var is 26 on exiting What is printed when f1() is called the second time f1: var is 25 on entering f1: var is 26 on exiting What is printed when f2() is called the second time? f2: var is 21 on entering f2: var is 22 on exiting What is printed when f3() is called the second time? f3: var is 10 on entering f3: var is 100 on exiting What is printed

Content preview

CPSC 1010 Exam 2 Review: Arrays, Array
Initialization, String Handling, strlen, strcat,
strcmp, Character Arrays, Integer Arrays, Loops,
printf Output, Function Calls, Scope, Local vs
Global Variables, Passing Arrays to Functions,
Return Values, Function Prototypes, Header Files,
#include Directives, Makefile Compilation,
Executable Naming, make Commands, Source File
Management, String Concatenation, String
Comparison, Null Terminator, Input/Output, Control
Flow, Variable Tracing, Debugging, C Syntax,
Pointers and Addresses, Array Indexing, Common
Errors, Code Documentation, Modular
Programming, Function Implementation vs
Prototype Exam Questions Verified and Provided
with A+ Graded Rationales Latest Updated 2026


Declare an array of 5 integers called array1 and initialize the array with the values 1-5.

int array1[5] = {1, 2, 3, 4, 5};

Is this a valid array declaration?
int array2[] = {1, 2, 3, 4, 5};

yes

What would print to the screen with this code?

int array3[5] = {1, 2, 3};
int i;
for(i = 0; i < 5; i++)
printf("%d ", array3[i]);

12300

, What would print to the screen with this code?

int array3[5] = {'1', '2', '3'};
int i;
for(i = 0; i < 5; i++)
printf("%d ", array3[i]);

49 50 51 0 0

How many characters are in this array?

char word1[] = {"CS for all"};

11 total

Finish this code to find the length of the string:

char word1[] = {"CS for all"};
int length;
// use strlen function

length = strlen(word1);

What value will the printf print?

char word1[] = {"CS for all"};
int length = strlen(word1);
printf("length of word1 is: %d\n" length);

10

How many characters are in this array?

char word2[] =
{'a', 'l', 'l', ' ', 'i', 'n'};

6 total

Write the code to combine the contents of the first three word arrays to produce the phrase "All
in for Clemson" in the phrase array.

char word3[] = {"All in "};
char word4[] = {'f', 'o', 'r', '\0'};

Document information

Uploaded on
February 26, 2026
Number of pages
7
Written in
2025/2026
Type
Exam (elaborations)
Contains
Questions & answers
$18.49

Wrong document? Swap it for free Within 14 days of purchase and before downloading, you can choose a different document. You can simply spend the amount again.
Written by students who passed
Immediately available after payment
Read online or as PDF

Seller avatar
Reputation scores are based on the amount of documents a seller has sold for a fee and the reviews they have received for those documents. There are three levels: Bronze, Silver and Gold. The better the reputation, the more your can rely on the quality of the sellers work.
LectDan
4.0
(48)
Sold
223
Followers
157
Items
8756
Last sold
1 week ago



Why students choose Stuvia

Created by fellow students, verified by reviews

Quality you can trust: written by students who passed their tests and reviewed by others who've used these notes.

Didn't get what you expected? Choose another document

No worries! You can instantly pick a different document that better fits what you're looking for.

Pay as you like, start learning right away

No subscription, no commitments. Pay the way you're used to via credit card and download your PDF document instantly.

Student with book image

“Bought, downloaded, and aced it. It really can be that simple.”

Alisha Student

Working on your references?

Create accurate citations in APA, MLA and Harvard with our free citation generator.

Working on your references?

Frequently asked questions