Last Updated: January 3, 2026
30 quizzes
Which declaration correctly creates an array of 10 integers initialized to 0?
Given int scores[5]; as a local variable, what is the state of its elements before explicit initialization?
Which 2D array declaration best represents a 3x4 grid of pixels?
How is the null terminator represented in a C-style string?
Which header must be included to use std::string?
Which operation safely concatenates two std::string objects?
What is sizeof(greeting) if char greeting[] = "Hi";?
Which access to a 2D array matrix[3][4] is valid?
Given std::string s = "abc"; what does s.length() return?
Which is the safest way to copy a C-style string into a fixed-size buffer?
Declare a 2D array of 3 rows and 4 columns of int named matrix
int matrix = { {1,2,3,4}, {5,6,7,8}, {9,10,11,12} };Click an option to fill the blank:
Initialize a C-style string with automatic null termination
char name[] "Alice";Click an option to fill the blank:
Append lastName to firstName using std::string
std::string fullName = firstName lastName;Click an option to fill the blank:
What is the output of this code?
1#include <iostream>
2int main() {
3 int arr[5] = {1, 2, 3};
4 for (int i = 0; i < 5; ++i) {
5 std::cout << arr[i] << " ";
6 }
7 return 0;
8}What does this program print?
1#include <iostream>
2#include <string>
3int main() {
4 std::string s = "C++";
5 s += " Programming";
6 std::cout << s.size() << " " << s[0] << " " << s.back() << "\n";
7 return 0;
8}What is the output?
1#include <iostream>
2#include <cstring>
3int main() {
4 char src[] = "Hello";
5 char dst[10] = "Hi";
6 std::strcat(dst, src);
7 std::cout << dst << "\n";
8 return 0;
9}What does this program output?
1#include <iostream>
2int main() {
3 int matrix[2][3] = { {1,2,3}, {4,5,6} };
4 int sum = 0;
5 for (int r = 0; r < 2; ++r) {
6 for (int c = 0; c < 3; ++c) {
7 sum += matrix[r][c];
8 }
9 }
10 std::cout << sum << "\n";
11 return 0;
12}What is the output of this std::string comparison?
1#include <iostream>
2#include <string>
3int main() {
4 std::string a = "apple";
5 std::string b = "banana";
6 if (a < b) std::cout << "less";
7 else std::cout << "not less";
8 std::cout << "\n";
9 return 0;
10}Find the bug related to C-style strings
Click on the line(s) that contain the bug.
#include <iostream>#include <cstring>int main() { char *name = "Alice"; name[0] = 'M'; std::cout << name << "\n"; return 0;}Find the bug in this 2D array code
Click on the line(s) that contain the bug.
#include <iostream>int main() { int rows = 2, cols = 3; int matrix[2][3] = { {1,2,3}, {4,5,6} }; for (int r = 0; r <= rows; ++r) { for (int c = 0; c < cols; ++c) { std::cout << matrix[r][c] << " "; } std::cout << "\n"; } return 0;}Click the line that risks buffer overflow for a C-style string
Click on the line to select.
#include <iostream>#include <cstring>int main() { char buf[5]; std::strcpy(buf, "Hello"); std::cout << buf << "\n"; return 0;}Click the line where std::string concatenation happens
Click on the line to select.
#include <iostream>#include <string>int main() { std::string first = "C++"; std::string second = "17"; std::string combined = first + " " + second; std::cout << combined << "\n"; return 0;}Fill blanks to read 5 integers into an array
#include <iostream>int main() { int scores[]; for (int i = 0; i < ; ++i) { std::cin >> scores[]; } return 0;}Click an option to fill blank 1:
Fill blanks to declare and initialize a C-style string with manual null terminator
char word[] = { 'O', 'K', };Click an option to fill blank 1:
Fill blanks to use std::string append and length
#include <iostream>#include <string>int main() { std::string s = "Hello"; s.(" World"); std::cout << s.() << "\n"; return 0;}Click an option to fill blank 1:
Fill blanks to declare and use a 2D array
int matrix[][] = { {1,2}, {3,4} };int sum = matrix[][] + matrix[1][1];Click an option to fill blank 1:
Match each string type with its description
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match each operation with the API it primarily relates to
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Order the steps to safely read input into a C-style string buffer
Drag and drop to reorder, or use the arrows.
Order steps to iterate over a 2D array and compute the total sum
Drag and drop to reorder, or use the arrows.