General Programming Flashcards

1
Q

A sequence of instructions that solves a problem is called …

A

an algorithm

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

A computer program consists of instructions executing one at a time. Basic instruction types are:

A

Input: A program gets data, perhaps from a file, keyboard, touchscreen, network, etc.
Process: A program performs computations on that data, such as adding two values like x + y.
Output: A program puts that data somewhere, such as to a file, screen, network, etc.

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

Programs use ( ) to refer to data, like x, y, and z below.

A

Variables. The name is due to a variable’s value varying as a program assigns a variable like x with new values.

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

Because a syntax error is detected by the compiler, a syntax error is known as a type of

A

compile-time error.

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

A logic error, also called a “____”, is an error that occurs while a program runs.

A

bug

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

Instructions represented as 0s and 1s are known as “_____”

A

machine instructions

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

a sequence of machine instructions together form an “_______”

A

executable program (sometimes just called an executable).

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

Because 0s and 1s are hard to comprehend, programmers soon created programs called “______” to automatically translate human readable instructions, such as “Mul 97, #9, 98”, known as “___________”, into machine instructions.

A

assemblers

assembly language instructions

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

In the 1960s and 1970s, programmers created “_________” to support programming using formulas or algorithms, so a programmer could write a formula like: F = (9 / 5) * C + 32.

A

high-level languages

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

To support high-level languages, programmers created “_______”, which are programs that automatically translate high-level language programs into executable programs.

A

compilers

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

The preprocessor reads a program before it is compiled and only executes those lines beginning with # symbol.

A

True

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

Escape sequences are always stored internally as a single character.

A

True

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

What is a Preprocessor directive and what does it start with?

A

Preprocessor directives are lines included in the code of programs preceded by a hash sign (#). These lines are not program statements but directives for the preprocessor. The preprocessor examines the code before actual compilation of code begins and resolves all these directives before any code is actually generated by regular statements.

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

In a cout statement, which of the following will advance the output position to the beginning of the next line?

A

endl or \n

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

What will the following code display?
int number = 23;
cout &laquo_space;“The number is “ &laquo_space;“number” &laquo_space;endl;

A

The number is number

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

A valid (_______ )is a sequence of one or more letters, digits or underscore characters (). Neither spaces nor punctuation marks or symbols can be part of an identifier. Only letters, digits and single underscore characters are valid. In addition, variable identifiers always have to begin with a letter. They can also begin with an underline character ( ), but in some cases these may be reserved for compiler specific keywords or external identifiers, as well as identifiers containing two successive underscore characters anywhere. In no case can they begin with a digit.

A

identifier

17
Q

An assignment statement uses the

A

= operator to store a value in a variable

18
Q

To initialize a variable means to

A

assign it a value when it is defined

19
Q

The scope of a variable:

A

the part of the program in which the variable can be accessed

20
Q

Arithmetic Operators

A

C++ has unary, binary, and ternary operators:
unary (1 operand) -5
binary (2 operands) 13-7
rernary (3 operands) exp1 ? exp2 : exp3

21
Q

What are the binary arithmetic operators

A

+, -, *, /, %

% is modulus and gives the remainder of division as its answer

22
Q

multi line comments begin and end with

A
/*
*/
23
Q

Named Constants

A
Named constant (constant variable):
variable whose content cannot be changed during program execution

Used for representing constant values with descriptive names:
const double Tax_Rate = 0.0675
const int NUM_SATES = 50:

often named in uppercase letters