Last Updated: January 3, 2026
30 quizzes
Which declaration correctly defines a local integer variable in C++?
What is the main benefit of using a named const instead of a literal like 100 scattered in code?
Which operator has the highest precedence in C++?
Which line correctly reads an int value from standard input?
Which C++ comment style is best for a short note at the end of a single line of code?
What happens when you convert a double to int using static_cast<int>(value)?
Which is a valid way to declare a constant double for Pi?
Which literal is a character literal?
Which expression uses a logical operator to check two conditions?
Which statement about std::cout and std::cin is correct?
Declare and initialize a boolean variable using a literal
bool isReady = ;Click an option to fill the blank:
Cast an int to double using static_cast
double d = static_cast<double>();Click an option to fill the blank:
Declare a constant integer representing a buffer size
const int = 1024;Click an option to fill the blank:
What is the output of this code?
1#include <iostream>
2int main() {
3 int a = 10;
4 int b = 3;
5 std::cout << a / b << " " << a % b << std::endl;
6 return 0;
7}What does this program print?
1#include <iostream>
2int main() {
3 bool flag = (5 > 3) && (2 == 4);
4 std::cout << flag << std::endl;
5 return 0;
6}Predict the output considering variable scope
1#include <iostream>
2int x = 5;
3void foo() {
4 int x = 10;
5 std::cout << x << " ";
6}
7int main() {
8 std::cout << x << " ";
9 foo();
10 std::cout << x << std::endl;
11 return 0;
12}What is the output regarding type casting?
1#include <iostream>
2int main() {
3 double price = 9.99;
4 int whole = static_cast<int>(price);
5 std::cout << price << " " << whole << std::endl;
6 return 0;
7}What does this I/O code print if the user enters: 25<Enter>John<Enter>?
1#include <iostream>
2#include <string>
3int main() {
4 int age;
5 std::string name;
6 std::cin >> age;
7 std::cin >> name;
8 std::cout << name << " is " << age << std::endl;
9 return 0;
10}Find the bug related to constants and assignment
Click on the line(s) that contain the bug.
#include <iostream>int main() { const int MAX_COUNT = 10; int count = 0; while (count < MAX_COUNT) { std::cout << count << " "; if (count == 5) { MAX_COUNT = 3; } ++count; } return 0;}Identify the bug involving uninitialized variables and I/O
Click on the line(s) that contain the bug.
#include <iostream>int main() { int value; if (value > 0) { std::cout << "Positive" << std::endl; } else { std::cout << "Non-positive" << std::endl; } return 0;}Click the line where an integer literal is used to initialize a variable
Click on the line to select.
#include <iostream>int main() { int x; x = 5; std::cout << x << std::endl; return 0;}Click the line that performs an explicit type cast
Click on the line to select.
#include <iostream>int main() { int total = 7; int count = 2; double avg1 = total / count; double avg2 = static_cast<double>(total) / count; std::cout << avg2 << std::endl; return 0;}Complete the code to declare and initialize variables with appropriate types and literals
#include <iostream>int main() { age = ; pi = ; std::cout << age << " " << pi << std::endl; return 0;}Click an option to fill blank 1:
Complete the code to read a full line of text and an integer
#include <iostream>#include <string>int main() { std::string name; int age; std::getline(, ); >> age; std::cout << name << " " << age << std::endl; return 0;}Click an option to fill blank 1:
Fill in the blanks to define and use a constant and a relational operator
#include <iostream>int main() { const int LIMIT = ; int value = 12; if (value LIMIT) { std::cout << "Too high" << std::endl; } return 0;}Click an option to fill blank 1:
Complete the code to demonstrate explicit casting in an arithmetic expression
#include <iostream>int main() { int sum = 7; int count = 2; double avg = static_cast<>() / count; std::cout << avg << std::endl; return 0;}Click an option to fill blank 1:
Match each literal type with an example
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Match each stream-related term with its description
Click an item on the left, then click its match on the right. Click a matched item to unmatch.
Order the steps to read an integer from input and print its double
Drag and drop to reorder, or use the arrows.
Order the steps to safely cast a double to int and print both values
Drag and drop to reorder, or use the arrows.