What is the purpose of the main() function in C++?
It’s the entry point of every C++ program where execution begins.
How do you declare an integer variable in C++?
int x = 5;
What are the basic data types in C++?
int, float, double, char, bool
How do you write a single-line comment in C++?
Use // before the comment text
How do you write a multi-line comment in C++?
Use /* comment */ syntax
What does #include <iostream> do?</iostream>
It allows input/output operations using cin and cout
How do you print text to the console in C++?
cout «_space;“Hello, world!”;
How do you take input from the user in C++?
cin»_space; variable;
What is a constant in C++?
A value that cannot be changed after initialization, declared using const
How do you declare a constant integer in C++?
const int MAX = 100;
What is a conditional statement?
A way to make decisions in code using if, else if, and else
What is the syntax of an if statement in C++?
if (condition) { /* code */ }
What are the three types of loops in C++?
for, while, do-while
How do you write a for loop in C++?
for (int i = 0; i < 5; i++) { /* code */ }
How do you write a while loop in C++?
while (condition) { /* code */ }
How do you write a do-while loop in C++?
do { /* code */ } while (condition);
What is a function in C++?
A reusable block of code that performs a specific task
How do you define a function in C++?
returnType functionName(parameters) { /* code */ }
What is the difference between int and float?
int stores whole numbers, float stores decimal numbers
What is a boolean value in C++?
A value that is either true or false
What is the modulus operator (%) used for?
It returns the remainder of a division
What is the scope of a variable?
The region of code where the variable is accessible
What is the purpose of return in a function?
It sends a value back to the caller of the function