Learncpp.com Flashcards
What is a statement in C++?
A statement is an instruction in a program that performs an action. Most statements in C++ end with a semicolon.
What are the different types of statements in C++?
Declaration, jump, expression, compound, selection (conditionals), iteration (loops), try blocks.
What is a function in C++?
A function is a collection of statements that are executed in order. Functions perform specific tasks and help organize the code.
Why is the main() function important in C++?
Every C++ program must have a main() function. It is where the program starts executing, and typically finishes after the last statement in main().
What does #include <iostream> do in C++?</iostream>
It includes the iostream library, allowing the program to use std::cout to read and write text to the console.
What does std::cout «_space;“Hello world!”; do in a C++
It prints the text “Hello world!” to the console.
What is the purpose of return 0; in C++?
It indicates successful execution of the program and ends the main() function.
What is syntax in C++?
Syntax refers to the rules that govern how C++ programs are constructed. Violating these rules results in syntax errors.
What happens if you forget the semicolon at the end of a statement in C++?
A syntax error occurs, and the compiler will not run the program until the error is fixed.
How can you fix a syntax error in C++?
Syntax errors are typically easy to find and fix because the compiler points to the line where the error occurred. Fixing the mistake and recompiling solves the issue.
What is a comment in programming?
A comment is a programmer-readable note inserted into the source code of the program. Comments are ignored by the compiler and help programmers document the code.
What are the two styles of comments in C++?
Single-line comments (//) and multi-line comments (/* */).
What are the three primary uses of comments?
1) Describe what a program or function does.
2) Describe how the code accomplishes its goal.
3) Explain why the code is doing something.
Why might you want to comment out code?
To exclude broken or incomplete code temporarily, debug issues, or revert to a previous working state.
What is a value?
A value is a letter (e.g. a), number (e.g. 5), text (e.g. Hello), or instance of some other useful concept that can be represented as data.