• ¿Documento equivocado? Cámbialo gratis
  • Escrito por estudiantes que aprobaron
  • Inmediatamente disponible después del pago
  • Leer en línea o como PDF
Vender
¿Dónde estudias?
Tu idioma
Document preview thumbnail
Vista previa 2 fuera de 7 páginas
Examen

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
Vista previa 2 fuera de 7 páginas

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

Vista previa del contenido

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'};

Información del documento

Subido en
26 de febrero de 2026
Número de páginas
7
Escrito en
2025/2026
Tipo
Examen
Contiene
Preguntas y respuestas
$18.49

¿Documento equivocado? Cámbialo gratis Dentro de los 14 días posteriores a la compra y antes de descargarlo, puedes elegir otro documento. Puedes gastar el importe de nuevo.
Escrito por estudiantes que aprobaron
Inmediatamente disponible después del pago
Leer en línea o como PDF

Seller avatar
Los indicadores de reputación están sujetos a la cantidad de artículos vendidos por una tarifa y las reseñas que ha recibido por esos documentos. Hay tres niveles: Bronce, Plata y Oro. Cuanto mayor reputación, más podrás confiar en la calidad del trabajo del vendedor.
LectDan
4.0
(48)
Vendido
223
Seguidores
157
Artículos
8756
Última venta
1 semana hace



Por qué los estudiantes eligen Stuvia

Creado por compañeros estudiantes, verificado por reseñas

Calidad en la que puedes confiar: escrito por estudiantes que aprobaron y evaluado por otros que han usado estos resúmenes.

¿No estás satisfecho? Elige otro documento

¡No te preocupes! Puedes elegir directamente otro documento que se ajuste mejor a lo que buscas.

Paga como quieras, empieza a estudiar al instante

Sin suscripción, sin compromisos. Paga como estés acostumbrado con tarjeta de crédito y descarga tu documento PDF inmediatamente.

Student with book image

“Comprado, descargado y aprobado. Así de fácil puede ser.”

Alisha Student

Preguntas frecuentes