2.1 The Parts of a C++ Program Flashcards

1
Q

//

A

Marks the beginning of a comment.

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

Are comments required?

A

Comments are not required, as the compiler ignores everything from the double slash to the end of the line. However, they are very helpful to programmers.

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

If a line starts with #, what is it called?

A

Preprocessor directive

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

What does the preprocessor do?

A

The preprocessor reads your program before it is compiled and only executes those lines beginning with a # symbol. Think of it as a program that “sets up” your source code for the compiler.

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

What does the #include directive causes the preprocessor to do?

A

To include the contents of another file in the program.

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

What is the word iostream inside the bracket <iostream>?</iostream>

A

It is the name of the file that is to be included.

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

Where should the header file be included?

A

At the top of the program.

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

C++ uses namespaces to do what?

A

To organize the names of program entities.

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

What does the statement using namespace std; declares?

A

It declares that the program will be accessing entities whose names are part of the namespace called std.

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

What does int main() marks?

A

It marks the beginning of a function.

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

What is a function?

A

A function can be thought of as a group of one or more programming statements that collectively has a name.

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

What does the word int stands for?

A

Integer

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

Every C++ program must have this function.

A

the main function aka
int main ()

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

#

A

Pound sign

Marks the beginning of a preprocessor directive.

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

<>

A

Opening and closing brackets

Encloses a filename when used with the #include directive.

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

( )

A

Opening and closing parentheses

Used in naming a function, as in int main ()

17
Q

{ }

A

Opening and closing braces

Encloses a group of statements, such as the contents of a function.

18
Q

” “

A

Opening and closing quotation marks

Encloses a string of characters, such as a message that is to be printed on the screen.

19
Q

;

A

Semicolon

Marks the end of a complete programming statement.