C1/2 Introduction Flashcards

Includes chapter 1-2.7 (73 cards)

1
Q

What is computational thinking?

A

Creating a sequence of instructions to solve a problem

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

What is an algorithm?

A

A sequence of instructions that solves a problem

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

What are the three main components of a computer program?

A
  • Input
  • Process
  • Output
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
4
Q

What does the input component of a computer program do?

A

Obtains data from sources (files, keyboard, touchscreen, network)

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

What does the process component of a computer program do?

A

Executes computations on the input data

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

What does the output component of a computer program do?

A

Displays or saves the processed data

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

What is a variable in programming?

A

Represents data; their values can change

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

Provide an example of how to assign a value to a variable in C++.

assign 2 to x

A

int x = 2;

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

What is the purpose of the preprocessor directive #include <iostream> in C++?</iostream>

A

Includes the standard input-output stream library

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

What does ‘using namespace std;’ allow in C++?

A

Use elements from the std (standard) namespace without prefixing

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

What does the statement ‘return 0;’ indicate in a C++ program?

A

The program ended successfully

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

How do you get input from the user in C++?

A

Using the statement cin&raquo_space; variable;

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

What does the cout statement do?

A

Outputs data to the console

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

What is the difference between cout and cin?

A

cout outputs data, cin gets input data

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

What does the statement cout &laquo_space;endl; do?

A

Outputs a newline character

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

What is a string literal?

A

Text in double quotes

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

What is a multi-line comment in C++?

A

Starts with /* and ends with */

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

What is a single-line comment in C++?

A

Starts with // and includes all following text on that line

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

Fill in the blank: A computer program can be analogized to a _______.

A

cooking recipe

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

What is the purpose of the statement ‘int main() {‘ in a C++ program?

A

Defines the main function where program execution begins

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

How do you declare an integer variable in C++?

A

Using the statement int variableName;

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

What is turtle graphics used for?

A

Instructing a robotic turtle to draw shapes using commands

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

What capability does the cout statement have regarding outputting multiple items?

A

The cout statement can output multiple items in one statement using the insertion operator («).

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

What does the statement ‘wage = 20;’ do in a C++ program?

A

Assigns the value 20 to the variable wage

How well did you know this?
1
Not at all
2
3
4
5
Perfectly
25
What is the significance of the statement cout << x; in a C++ program?
Outputs the value of variable x
26
What is the typical unit of measurement for angles when drawing shapes in turtle graphics?
Degrees
27
What is a multi-line comment in programming?
A comment that spans multiple lines, usually enclosed in /* ... */
28
What is whitespace in programming?
Blank spaces and newlines that are mostly ignored by the compiler
29
Does a compiler ignore all instances of whitespace in a program?
Although a compiler generally ignores whitespace, such as spaces and newlines, for the structure of code, it doesn't ignore whitespace that affects program semantics, like in string literals.
30
What is the recommended practice for separating conceptually distinct statements?
Use blank lines
31
How should operators be spaced for readability?
Use a single space before and after any operators like =, +, *, or <<
32
What does a compiler do when it encounters a syntax error?
Generates an error message indicating something is wrong with the code’s syntax
33
What is a semantic error?
Occurs when the syntax is correct, but the code doesn’t do what the programmer intended
34
What is a logic error?
An error when the program runs successfully but produces incorrect results
35
What is a bit?
The most basic unit of information in a computer, which can be either 0 or 1
36
How is a circuit defined in computing?
Combinations of switches wired together to perform calculations
37
What is the purpose of assembly language?
A more human-readable way to write instructions compared to machine code
38
Fill in the blank: A compiler generates a message when encountering a _______.
syntax error
39
What is the significance of warnings from a compiler?
They point out potential problems but do not stop the program from being created
40
What should you do when a compiler reports multiple errors?
Focus on fixing just the first error reported and then recompiling
41
What does the prefix '0h' indicate in programming?
A hexadecimal number
42
How are numbers represented when there is no prefix or suffix?
Numbers without both a prefix and suffix are interpreted as decimal numbers.
43
What is the ASCII value for 'A'?
65
44
What should be done if you encounter a compiler warning?
Treat warnings seriously and fix them
45
What is the result of the expression numToBuy = numNeeded - numInStock + 2?
The number of items to buy based on the stock
46
What does 0 represent in binary?
False
47
What does 1 represent in binary?
True
48
What are machine instructions?
The raw 0s and 1s that the processor understands directly.
49
What is assembly language?
A more human-readable way to write instructions.
50
What do assemblers do?
Translate assembly language into machine instructions.
51
Give an example of a high-level programming language.
Python, Java, C++
52
What is the role of compilers?
Programs that translate high-level language code into executable programs.
53
What analogy is used to describe the processor's function?
A chef following a recipe.
54
What is memory in computing?
Where data and instructions needed by the processor are stored.
55
How does memory work?
Like a series of mailboxes with addresses storing 0s and 1s.
56
What types of data are stored in memory?
Instructions for the processor and the data it's working on.
57
What does RAM stand for?
Random Access Memory
58
What do processors (CPUs) do?
Execute instructions and perform calculations.
59
What is a program?
A sequence of instructions designed to perform a specific task.
60
What is the origin year of the C programming language?
1978
61
Who created the C programming language?
Brian Kernighan and Dennis Ritchie
62
What is C++?
An enhancement of C created by Bjarne Stroustrup in 1985.
63
What programming paradigm did C++ introduce?
Object-Oriented Programming (OOP)
64
What does the ++ in C++ signify?
An enhancement over C.
65
Name a real-world application developed using C++.
Photoshop, Windows
66
What percentage of programming-related searches do C, C++, and C# account for?
35%
67
What year was the first C++ book published?
1985
68
What does C# primarily develop?
Microsoft Windows applications.
69
What is Objective-C used for?
Developing applications on iPhone, iPad, and Mac platforms.
70
What is a key feature of Java related to C/C++?
Portability across different operating systems.
71
Fill in the blank: The variable wage holds the value 20. The variable wage can be assigned with a different value later in the program, so it is called a _______.
variable
72
What impact did C have on UNIX?
It was pivotal in implementing UNIX.
73
What is the significance of understanding the evolution from C to C++?
It helps appreciate the ongoing relevance and application of these languages.