2.2 Variables, constants, inputs, outputs and assignments Flashcards

1
Q

What is a variable?

A

A value stored in memory that can change while the program is running

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

What is a constant?

A

A value that does not change while the program is running, and is assigned when the program is designed

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

What is assignment?

A

Giving a variable or constant a value

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

What is casting?

A
  • Converting a variable from one data type to another e.g. integer to a string
  • A variable can be an integer, character, string, real (float), or Boolean
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
5
Q

What is an input?

A

A value is read from an input device e.g. keyboard

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

What is an output?

A

Data generated by the computer and displayed to the user

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

What are the advantages of constants?

A
  • Constants make a program easier to read as they are usually declared and assigned at the top of the program
  • Constants can easily be changed by the programmer in one place in a program
  • Instead of changing every instance of a value throughout a program
  • This leads to less chance of errors
  • The compiler can optimise the code - this makes a program run more quickly if constants are used instead of variables
How well did you know this?
1
Not at all
2
3
4
5
Perfectly
8
Q

Why is casting needed?

A
  • Casting changes a variable from one data type to another e.g. a string to an integer
  • Inputs from the keyboard are always characters. Multiple characters are called a string
  • However to perform an addition, the ALU must use numbers - therefore a string must be cast to a number
How well did you know this?
1
Not at all
2
3
4
5
Perfectly