Inputs/Outputs/Variables/Data Types
Conditionals
Loops
Arrays & 2D Arrays
Functions
100

What would the data type be for a variable that holds the message "I love coding!" ?

string

100

Given an integer N. Your task is to check if the integer is greater than, less than or equal to 5. What kind of conditional statement do you use?

if statement

100

for (int i = 0; i<5; i++) {

    cout << i << " ";

}


What is the output?

0 1 2 3 4

100

How do you access the fourth element of an array named "numbers"?

numbers[3]

100

What's the name of the variables that go in the paranthesis when you call a function? (ex: myfunction(thisvariable) )

parameter

200

What are the keywords for inputs and outputs?

cin and cout

200

in1 = True

in2 = True

in3 = False

out = not (in1 and not in2) or in3

What does 'out' end up outputting?

True

200

What is the "break" and "continue" keywords used for?

"break" is used for aborting and "continue" is used for moving past but not aborting 
200

In a 2D array what is the first number and the second number in the declaration a depiction of?

The first number is the number of arrays and the second number is the number of elements in the array.

200

bool frog(int a, int b) {

    return a > b;

}

What are the parameters for the function frog?

a and b

300

What is the library used for inputs/outputs?

iostream or #include <iostream>

300

What conditional statement it used when you have exhausted every other statement?

else statement

300

string fruits = {"orange", "banana", "apple", "cherry", "strawberry"};

for (int i=0; i<2; i++) {

    for (int j=0; j<5; j++) {

         cout << fruits[j][0] << " ";

    }

cout << endl;

}


What is the output?

o b a c s

o b a c s

300

In a 2D array, how do I access the third element of the fourth array from the 2D array "names"?

names[3][2]

300

Given integers a and b, a function returns a>b. What is the data type of the output of this function?

boolean

400

What are the two ways we move onto the next line in C++?

"\n" and endl

400

int num = 15;   

if (num < 20) {        

   cout << "The number is less than 20.";    

}    

else if (num < 16){ 

   cout << "The number is less than 16.";    }


What is the output here?

The number is less than 20

400

for (int j = 0; j < 5; j++) {

   for (int z = 0; z < j; z++) {

      cout << "*";

   }

   cout << endl;

}

*

**

***

****

400

In a 2D array called "step" of size NxN, how do we access the last element of the last array?

step[N - 1][N - 1]

400

What is the return type if I don't want to return anything?

void

500

What is the total amount of bits an integer, double, float can hold? (Add them up)

128

500

Write a complete C++ "if-else" statement to determine if a given integer variable "num" is positive, negative, or zero, and print the result accordingly.

If it's good it's good

500

int n, variable = 1;    

std::cout << "Enter a positive integer: ";    

std::cin >> n;    

for (int i = 1; i <= n; i++) {        

   variable *= i;    

}

What is this program doing?

Getting the factorial of n

500

int arr[] = {10, 20, 30, 40, 50}; 

int n = sizeof(arr) / 4;    

int sum = 0;    

for (int i = 0; i < n / 2; i++) {        

   sum += arr[i] * arr[n - 1 - i];    

}    

cout << sum;

What does this output?

1300

500

Explain the difference between function declaration and function definition.

Function declaration: When the function is first introduced (ex: int main() )

Function definition: When what the function does is written out in code

M
e
n
u