
C++ Programming- Arrays
Quiz by Sandhya
Feel free to use or edit a copy
includes Teacher and Student dashboards
Measure skillsfrom any curriculum
Measure skills
from any curriculum
Tag the questions with any skills you have. Your dashboard will track each student's mastery of each skill.
With a free account, teachers can
- edit the questions
- save a copy for later
- start a class game
- automatically assign follow-up activities based on students’ scores
- assign as homework
- share a link with colleagues
- print as a bubble sheet
10 questions
Show answers
- Q1In C++, how do you declare an array named 'numbers' with 5 elements of type int?array numbers[5];numbers = int[5];int numbers[5];int[] numbers = new int[5];30s
- Q2How do you access the fourth element in an array named 'scores' in C++?scores{4};scores[3];scores$4;scores(3);30s
- Q3What is the syntax to assign the value 10 to the third element in an array named 'data' in C++?data[2] = 10;assign data[2] = 10;10 = data[2];data{2} = 10;30s
- Q4How do you iterate through all elements of an array named 'ages' and print each element in C++?for(int i = 0; i < sizeof(ages) / sizeof(ages[0]); i++) { cout << ages[i] << ' '; }while(int i = 0; i < ages.length; i++) { cout << ages[i] << ' '; }for(int i = 1; i < sizeof(ages); i++) { cout << ages[i] << ' '; }foreach(int i in ages) { cout << i << ' '; }30s
- Q5What is the correct way to declare a 2D array named 'matrix' with 3 rows and 4 columns in C++?int matrix = new int[3][4];int matrix(3, 4);int matrix[3][4];matrix = int[3][4];30s
- Q6What is the syntax to access the value at row 1, column 2 in a 2D array named 'grid' in C++?grid{1, 2};grid(1, 2);grid$1$2;grid[1][2];30s
- Q7What is the output of the following code snippet in C++? int numbers[] = {10, 20, 30, 40, 50}; cout << numbers[2];5040103030s
- Q8How do you find the number of elements in an array named 'myArray' in C++?length(myArray)sizeOfArray(myArray)countElements(myArray)sizeof(myArray) / sizeof(myArray[0])30s
- Q9What is an array in C++?A function that calculates the sum of elements in a sequence.A type of loop used for iteration in C++.A standard input/output operation in C++.A collection of elements of the same data type stored in contiguous memory locations.30s
- Q10How do you use a loop to initialize an array named 'scores' with values 1 to 10 in C++?while(scores <= 10) { scores[scores] = i; i++; }for(int i = 0; i < 10; i++) { scores[i] = i + 1; }for(int i = 1; i <= 10; i++) { scores[i-1] = i; }for(int i = 1; i < 11; i++) { scores[i] = i; }30s