1.1 — Statements and the structure of a program

0.0(0)
studied byStudied by 0 people
learnLearn
examPractice Test
spaced repetitionSpaced Repetition
heart puzzleMatch
flashcardsFlashcards
Card Sorting

1/31

flashcard set

Earn XP

Description and Tags

https://www.learncpp.com/cpp-tutorial/statements-and-the-structure-of-a-program/

Study Analytics
Name
Mastery
Learn
Test
Matching
Spaced

No study sessions yet.

32 Terms

1
New cards

What is the goal of the first chapter of the C++ tutorial?

To help you understand how basic C++ programs are constructed

2
New cards

What type of instruction causes a C++ program to perform some action?

A statement

3
New cards

What do most C++ statements end with?

A semicolon

4
New cards

What is the smallest independent unit of computation in C++?

A statement

5
New cards

What is the function in which every C++ program must start?

main

6
New cards

What happens when the program is run?

The statements inside main are executed in sequential order

7
New cards

What is the term for a sequence of characters?

Text or string

8
New cards

What does the #include line do?

It includes the iostream library needed for input and output

9
New cards

What symbol is used to mark the beginning and end of a function body?

Curly braces {}

10
New cards

What does std::cout do?

Displays output to the console

11
New cards

What value is returned by return 0; in the main function?

It returns 0, meaning the program executed successfully

12
New cards

What is a preprocessor directive in C++?

A command that runs before compilation, like #include

13
New cards
<p>What is the name of the rule system that dictates how a program must be written?<br><br>#include &lt;iostream&gt;</p><p>int main()</p><p>{</p><p>   std::cout &lt;&lt; "Hello world!";</p><p>   return 0;</p><p>}</p>

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

14
New cards

What does the compiler do when it encounters a syntax error?

Halts compilation and issues an error message

15
New cards

What is an identifier in programming?

The name of a function, object, type, etc.

16
New cards

What is the shorthand for referring to a function named main?

main()

17
New cards

What is the visible output of the Hello World program?

Hello world!

18
New cards

What does the compiler do with blank lines in code?

Ignores them

19
New cards

What kind of character is not displayed or displays in a special way?

A control character

20
New cards

What kind of function might calculate a student’s grade?

calculateGrade()

21
New cards

What will happen if the semicolon is missing at the end of a statement?

The compiler will generate a syntax error

22
New cards
<p>Which line in the Hello World example marks the start of the main function’s body?</p>

Which line in the Hello World example marks the start of the main function’s body?

Line 4

23
New cards

What is the purpose of std::cout << "Hello world!";?

To output “Hello world!” to the console

24
New cards

Which control character creates spacing similar to spaces?

Tab

25
New cards

What lesson discusses cout, cin, and endl?

Lesson 1.5

26
New cards

What is a statement?

an instruction in a computer program that tells the computer to perform an action.

27
New cards

What is a function?

A function is a collection of statements that executes sequentially.

28
New cards

What is the name of the function that all programs must have?

main

29
New cards

What happens when the program is run?

The statements inside main() are executed in sequential order.

30
New cards

What symbol are statements in C++ often ended with?

A semicolon (;)

31
New cards

What is a syntax error?

A syntax error occurs when your program violates the grammar rules of the C++ language.

32
New cards

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.