Which header must be included to use std::cout and std::cin in standard C++?
Cpp Cpe Syntax Literals Operators
Question · Medium
What is the output of this program? #include <iostream> int main() { int a = 7; int b = 2; std::cout << a / b << " " << a % b; return 0; }
Question · Easy
Which of the following is a valid C++ identifier?
Tech Exam Prep Podcast
Listen on Spotify
Podcast
What value is printed by the following program? #include <iostream> int main() { int x = 10; std::cout << (x++ + ++x); return 0; }
Question · Hard
Which literal in C++ has type double by default?
What does the bitwise expression (5 & 3) evaluate to?
Given int x = 8; what does the expression (x << 2) produce?
Which of the following correctly declares a constant integer named MAX with value 100?
What is the output of this program? #include <iostream> int main() { int a = 5; int b = 3; std::cout << (a > b ? a - b : b - a); return 0; }
What does the expression (15 ^ 9) evaluate to?
What is the output of this program? #include <iostream> int main() { int x = 4; x += 6; x *= 2; std::cout << x; return 0; }
Which of the following correctly reads an integer from standard input into the variable n?
What is printed by this program? #include <iostream> int main() { bool flag = true; std::cout << flag << " " << !flag; return 0; }
Which statement about sizeof(char) is guaranteed by the C++ standard?
What is the output of this snippet? #include <iostream> int main() { int x = 10; std::cout << (x > 5 && x < 20); return 0; }
Which manipulator inserts a newline character and flushes the output stream?
What is the output of this program? #include <iostream> #include <iomanip> int main() { double pi = 3.14159265; std::cout << std::fixed << std::setprecision(2) << pi; return 0; }
Which of the following is the correct way to declare an unsigned integer variable in C++?
What does the expression !(5 == 5 || 3 > 4) evaluate to?
What is the result of (10 / 3.0) in C++?
Which expression correctly assigns the absolute difference between two ints a and b to int diff using the conditional operator?
What is the output of this program? #include <iostream> int main() { int a = 5; int b = a++; std::cout << a << " " << b; return 0; }
Which of the following character escape sequences represents a tab character?
What value does this expression produce? int x = 14; int y = 4; int r = x % y;
Which statement about operator precedence is TRUE in standard C++?
What is the output of this program? #include <iostream> int main() { int a = 6, b = 3, c = 2; std::cout << a + b * c; return 0; }
Which of the following correctly converts an int to a double using a C++-style cast?
What does the bitwise NOT (~) of an int 5 produce, assuming a 32-bit two's-complement int?
What is the output of this program? #include <iostream> int main() { char c = 'A'; std::cout << static_cast<int>(c); return 0; }
Which line correctly initializes an int variable using uniform initialization (brace initialization, C++11)?
Which statement about the for loop in C++ is correct? for (init; condition; update) { body }
Cpp Cpe Flow Control Functions
What is the output of this program? #include <iostream> int main() { int sum = 0; for (int i = 1; i <= 5; ++i) { sum += i; } std::cout << sum; return 0; }
What does the keyword 'continue' do inside a loop?
What is printed by this program? #include <iostream> int main() { int i = 0; while (i < 3) { std::cout << i << " "; ++i; } return 0; }
How does a do-while loop differ from a while loop?
What does the following switch statement print when x is 2? switch (x) { case 1: std::cout << "one"; break; case 2: std::cout << "two"; case 3: std::cout << "three"; break; default: std::cout << "other"; }
Which function definition correctly declares a function add that takes two ints and returns their sum?
What is the output of this program? #include <iostream> void increment(int n) { n = n + 1; } int main() { int x = 5; increment(x); std::cout << x; return 0; }
Which function declaration correctly takes an int by reference so the function can modify the caller's variable?
What is the output of this program? #include <iostream> void increment(int& n) { ++n; } int main() { int x = 10; increment(x); std::cout << x; return 0; }
Which statement about default arguments in C++ functions is TRUE?
Which of the following correctly demonstrates function overloading in C++?
What is the output of this recursive function? #include <iostream> int factorial(int n) { if (n <= 1) return 1; return n * factorial(n - 1); } int main() { std::cout << factorial(5); return 0; }
What does this Fibonacci-style function return for fib(5)? int fib(int n) { if (n < 2) return n; return fib(n - 1) + fib(n - 2); }
What is the output of this program? #include <iostream> int main() { for (int i = 0; i < 5; ++i) { if (i == 3) break; std::cout << i; } return 0; }
What is the output of this program? #include <iostream> int main() { for (int i = 0; i < 5; ++i) { if (i % 2 == 0) continue; std::cout << i; } return 0; }
What does this function return when called as power(2, 4)? int power(int base, int exp) { if (exp == 0) return 1; return base * power(base, exp - 1); }
Loading more…