Topic 8. Programming Flashcards

You may prefer our related Brainscape-certified flashcards:
1
Q

What are the data types?

A

Integer
Real
Char
String
Boolean

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

What type of data is an integer?

A

A whole number (5.-267.153489)

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

What type of data is a real?

A

A number with a decimal point (3.142,56.0,-0.75)

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

What type of data is a char?

A

A single character enclosed in single quotes (‘A’,’#’,’6’,’&’)

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

What type of data is a string?

A

Zero or more characters enclosed in double quotes (“Yes”,”Hi, John”)

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

What is a constant?

A

A named piece of memory where the value cannot be changed while a program runs.

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

What is a variable?

A

A location in memory that holds one or more values.

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

How do you declare a constant in pseudocode?

A

CONSTANT VAT <— 0.2

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

How do you declare a variable in pseudocode?

A

A variable is assigned a value in pseudocode using the <—

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

Write pseudocode which asks the user to enter two numbers representing the length and width of a rectangle, then calculates and prints the area

A

INPUT length
INPUT width
OUTPUT “Area = “, Length * Width

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

What are the arithmetic operators and what do they mean?

A

+ addition
- subtraction
/ division
* multiplication
^ raised to the power of
MOD modulus (The remainder that is left over when a number is divided by another)
DIV Quotient (Integer division divides two integers and discards any remainder)

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

What are the logical operators and what do they mean?

A

= Equal to
< Less than
<= Less than or equal
> Greater than
=> Greater than or equal
<> Not equal to

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

What is a boolean expression?

A

The expressions that evaluate a condition and result in a Boolean value i.e true or false.

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

What is a sequence?

A

Two or more statements written and executed one after the other in sequence

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

What is a selection statement?

A

A selection statement comprises an IF or CASE statement and a logical expression

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

What is a boolean operators?

A

The logical operators AND and OR are used to combine two or more conditions
The logical operator NOT may be used to test whether a condition is NOT satisfied

17
Q

When do we use an IF statement?

A

An IF statement may be nested inside another IF statement. For example suppose we wanted to output the largest of three numbers entered. The pseudocode could be written:

IF Num 1>= Num2 AND Num1 >= Num3

THEN
OUTPUT Num1

ELSE
IF Num 2 >= Num 1 AND Num 2 >= Num3
THEN
OUTPUT Num2
ELSE
OUTPUT Num 3

 ENDIF

ENDIF

18
Q

How would you use a for loop?

A

EXAMPLE

This code will print all the numbers between 1 and 10:

FOR count <— 1 TO 10
OUTPUT Count
NEXT Count

19
Q

What is a FOR loop?

A

A count-controlled loop

20
Q

What is a WHILE loop?

A

A pre-conditioned loop controlled by a Boolean condition which is checked before the loop is entered