Recall & Review
beginner
What is the starting point of execution in a C++ program?
The main() function is the starting point where the program begins execution.
Click to reveal answer
beginner
What is the purpose of
#include directives in a C++ program?They tell the compiler to include the contents of a file, usually a library, so you can use its functions and features.
Click to reveal answer
beginner
What does
using namespace std; do in a C++ program?It allows you to use names from the
std namespace (like cout and endl) without writing std:: before them.Click to reveal answer
beginner
Identify the parts of this simple C++ program:<br>
#include <iostream>
using namespace std;
int main() {
cout << "Hello, world!" << endl;
return 0;
}1.
#include <iostream> - includes input/output library.<br>2. using namespace std; - allows using standard names.<br>3. int main() - main function where execution starts.<br>4. cout << "Hello, world!" << endl; - prints text.<br>5. return 0; - ends the program successfully.Click to reveal answer
beginner
Why do we write
return 0; at the end of main()?It tells the operating system that the program finished successfully. Zero usually means no errors.
Click to reveal answer
Which function is the entry point of every C++ program?
✗ Incorrect
The
main() function is where execution starts in C++.What does
#include <iostream> do?✗ Incorrect
It includes the standard input/output library so you can use
cout and cin.What is the purpose of
using namespace std;?✗ Incorrect
It lets you use standard library names without the
std:: prefix.What does
return 0; mean in main()?✗ Incorrect
Returning zero signals successful program completion to the operating system.
Which line prints text to the screen in this code?<br>
int main() {
cout << "Hi!" << endl;
return 0;
}✗ Incorrect
The
cout line sends text to the screen.Describe the basic structure of a simple C++ program and explain the role of each part.
Think about what each line does from top to bottom.
You got /5 concepts.
Why is the
main() function important in C++? What happens if it is missing?Consider what the computer looks for to start running your code.
You got /4 concepts.