Which data type could be used to store decimal numbers?
float or double
What is the primary difference between while and for loops?
A for loop is generally used when the number of iterations is known,
A while loop is used when the number of iterations is not known.
A storage location identified by a name that can hold data and may be changed during program execution.
variable
What is the output of the following code?
int x = 3, y = 5;
if (x > y && x != y) {
cout << "X";
} else if (x < y || x == y) {
cout << "Y"; }
Y
What is the purpose of a loop in programming?
To repeat a block of code multiple times
How do you read user input in C++?
cin>>x;
What happens if an if statement's condition evaluates to false and there's no else statement?
The if block is skipped, and the program continues
The term for the operation of joining variables and strings together to form a single string.
Concatenation
What is the value of x after the following code executes?
int x = 5;
x += 10;
15
How do you exit out of a loop early in C++?
break; command
Which operator(s) is used for equality comparison?
==
What is the correct syntax for setting up a for loop?
for (i = 0; i < 5; i++)
Answer may vary - same setup
In C++, what is the purpose of using a continue; command inside a loop?
It skips the rest of the loop body for the current iteration.
int a = 5;
if (a < 10) {
a += 5;
}
cout << a;
10
To generate a pseudo-random integer within a specified range you'd call in what function?
rand( )
How do you define a constant in C++?
const int X = 10;
What is a possible consequence of having a while loop with a condition that is always true?
Program will enter an infinite loop and eventually crash
What is an algorithm in the context of computer science?
A step-by-step procedure or set of rules to solve a problem or perform a task.
int i = 10;
while (i > 0) {
cout << i << " ";
i -= 2;
}
10 8 6 4 2
What is an example of a preprocessor directive in C++?
#include<iostream>
#include ....
What does the term "sequencing" refer to in programming?
The order in which statements are executed.
In a for loop, which part is executed only once, at the very beginning?
The initialization expression
An informal way to describe an algorithm using structured but plain language, making it easier to understand.
Pseudocode
What will the following code print?
int x = 3, y = 5;
if (x > y && x != y) {
cout << "X";
} else if (x < y || x == y) {
cout << "Y";
}
Y
The set of rules that defines the structure and format of valid statements in a programming language is called it's WHAT?
Syntax