1/31
https://www.learncpp.com/cpp-tutorial/statements-and-the-structure-of-a-program/
Name | Mastery | Learn | Test | Matching | Spaced |
---|
No study sessions yet.
What is the goal of the first chapter of the C++ tutorial?
To help you understand how basic C++ programs are constructed
What type of instruction causes a C++ program to perform some action?
A statement
What do most C++ statements end with?
A semicolon
What is the smallest independent unit of computation in C++?
A statement
What is the function in which every C++ program must start?
main
What happens when the program is run?
The statements inside main are executed in sequential order
What is the term for a sequence of characters?
Text or string
What does the #include
It includes the iostream library needed for input and output
What symbol is used to mark the beginning and end of a function body?
Curly braces {}
What does std::cout do?
Displays output to the console
What value is returned by return 0; in the main function?
It returns 0, meaning the program executed successfully
What is a preprocessor directive in C++?
A command that runs before compilation, like #include
What is the name of the rule system that dictates how a program must be written?
#include <iostream>
int main()
{
std::cout << "Hello world!";
return 0;
}
Syntax
What does the compiler do when it encounters a syntax error?
Halts compilation and issues an error message
What is an identifier in programming?
The name of a function, object, type, etc.
What is the shorthand for referring to a function named main?
main()
What is the visible output of the Hello World program?
Hello world!
What does the compiler do with blank lines in code?
Ignores them
What kind of character is not displayed or displays in a special way?
A control character
What kind of function might calculate a student’s grade?
calculateGrade()
What will happen if the semicolon is missing at the end of a statement?
The compiler will generate a syntax error
Which line in the Hello World example marks the start of the main function’s body?
Line 4
What is the purpose of std::cout << "Hello world!";?
To output “Hello world!” to the console
Which control character creates spacing similar to spaces?
Tab
What lesson discusses cout, cin, and endl?
Lesson 1.5
What is a statement?
an instruction in a computer program that tells the computer to perform an action.
What is a function?
A function is a collection of statements that executes sequentially.
What is the name of the function that all programs must have?
main
What happens when the program is run?
The statements inside main()
are executed in sequential order.
What symbol are statements in C++ often ended with?
A semicolon (;
)
What is a syntax error?
A syntax error occurs when your program violates the grammar rules of the C++ language.
What is the C++ Standard Library?
A library file is a collection of precompiled code that has been “packaged up” for reuse in other programs.
The C++ Standard Library is a library that ships with C++. It contains additional functionality to use in your programs.