Keyword is used to display text to the screen in C++.
cout
What does the operator != do?
Checks if two values are not equal.
What will this code output if age = 20?
if (age >= 18) {
cout << "You can vote!";
}
“You can vote!”
Who created the C++ programming language?
Bjarne Stroustrup
What does the following code do?
int num = 5;
cout << num << endl;
Displays the value of num (which is 5)
What does x > y check?
Checks if x is greater than y.
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.
What does IPO stand for?
Input,Process, Output
Which of the following is a valid variable name?
a) 3dGraph
b) _employee_num
c) Mixture#3
b) _employee_num
Write a simple if statement that checks if a variable score is greater than or equal to 50.
if (score >= 50) {
cout << "You passed!";
}
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.
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.
int main() { cout << "Hello World"; }
#include <iostream> and using namespace std; should be added.
What are all the relational operators?
><,==,!=,<=>=
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.
What is C++ often used to create?
C++ is often used to create video games and software that needs to run fast.
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.
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.
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.
What does #include <iostream> do in a C++ program?
It lets you use input and output functions like cout and cin