C++ Syntax & Basics
Relational Operators
If Statements
Fun C++ Facts
100

Keyword is used to display text to the screen in C++.

cout

100

What does the operator != do? 

Checks if two values are not equal.

100

What will this code output if age = 20?

if (age >= 18) {

    cout << "You can vote!";

}

“You can vote!”

100

Who created the C++ programming language?

Bjarne Stroustrup

200

What does the following code do?

int num = 5;

cout << num << endl;


Displays the value of num (which is 5)

200

What does x > y check?

Checks if x is greater than y.

200

Correct the following code to display a message when the temperature is below 15°C:

if (temperature < 15)

    cout << "Wear a jacket";


 

The code is correct. It displays “Wear a jacket” if the temperature is less than 15°C.

200

What does IPO stand for?

Input,Process, Output

300

Which of the following is a valid variable name?

a) 3dGraph

b) _employee_num

c) Mixture#3

b) _employee_num

300

Write a simple if statement that checks if a variable score is greater than or equal to 50.

if (score >= 50) {

    cout << "You passed!";

}


300

What is the difference between if and if-else statements?

An if statement only executes code when a condition is true. An if-else statement provides two branches: one for when the condition is true and one for when the condition is false.

300

In C++, what does the // symbol represent?

The // symbol is used to create single-line comments in C++. Anything following // on the same line is considered a comment and is ignored by the compiler.

400

int main() {     cout << "Hello World"; }

#include <iostream> and using namespace std; should be added.

400

What are all the relational operators?


><,==,!=,<=>=

400

How do you use multiple conditions in an if statement?

Multiple conditions in an if statement can be combined using logical operators such as && (AND) and || (OR). These operators allow you to test multiple conditions at once.

400

What is C++ often used to create?

C++ is often used to create video games and software that needs to run fast.

500

In C++, what is the purpose of the #include directive, and how does it affect the program?

The #include directive is used to include external files, such as libraries, into the program.It essentially brings in pre-written code that the program can use to perform specific tasks.

500

What is the primary function of relational operators in programming?

Relational operators are used to compare two values and determine the relationship between them (e.g., greater than, less than, equal to). They return a boolean value (true or false) based on the comparison.

500

What is a nested if statement?

A nested if statement is an if statement inside another if statement. It allows you to test additional conditions if the first condition is true. This is useful for more complex decision-making processes.

500

What does #include <iostream> do in a C++ program?

It lets you use input and output functions like cout and cin

M
e
n
u