Learncpp.com Flashcards

1
Q

What is a statement in C++?

A

A statement is an instruction in a program that performs an action. Most statements in C++ end with a semicolon.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
2
Q

What are the different types of statements in C++?

A

Declaration, jump, expression, compound, selection (conditionals), iteration (loops), try blocks.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
3
Q

What is a function in C++?

A

A function is a collection of statements that are executed in order. Functions perform specific tasks and help organize the code.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

Why is the main() function important in C++?

A

Every C++ program must have a main() function. It is where the program starts executing, and typically finishes after the last statement in main().

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What does #include <iostream> do in C++?</iostream>

A

It includes the iostream library, allowing the program to use std::cout to read and write text to the console.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
6
Q

What does std::cout &laquo_space;“Hello world!”; do in a C++

A

It prints the text “Hello world!” to the console.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
7
Q

What is the purpose of return 0; in C++?

A

It indicates successful execution of the program and ends the main() function.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

What is syntax in C++?

A

Syntax refers to the rules that govern how C++ programs are constructed. Violating these rules results in syntax errors.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
9
Q

What happens if you forget the semicolon at the end of a statement in C++?

A

A syntax error occurs, and the compiler will not run the program until the error is fixed.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
10
Q

How can you fix a syntax error in C++?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
11
Q

What is a comment in programming?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
12
Q

What are the two styles of comments in C++?

A

Single-line comments (//) and multi-line comments (/* */).

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
13
Q

What are the three primary uses of comments?

A

1) Describe what a program or function does.
2) Describe how the code accomplishes its goal.
3) Explain why the code is doing something.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
14
Q

Why might you want to comment out code?

A

To exclude broken or incomplete code temporarily, debug issues, or revert to a previous working state.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
15
Q

What is a value?

A

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.

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
16
Q

What is an object?

A

An object is a region of storage (usually memory) that can store a value.

17
Q

What is a variable?

A

A variable is an object that has a name.

18
Q

What is an identifier?

A

An identifier is the name that a variable is accessed by.

19
Q

What is a data type used for?

A

A data type determines what kind of value (e.g. a number, a letter, text, etc…) the object will store.

20
Q

What is an integer? (int)

A

An integer is a number that can be written without a fractional component.