Variables in C Flashcards

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

What is a variable?

A

References to memory locations

Allow us to use names rather than memory addresses to access and manipulate data

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

Types of variable

A

char
int
double
float

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

Variable type qualifiers

A

signed - can hold positive and negative numbers
unsigned - can only hold positive numbers
short - –32768 to 32,767
long - –2,147,483,648 to 2,147,483,647

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

sizeof() does what?

A

used to check the size of a variable in bytes

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

Where must variables be declared?

A

They must be declared in the variable declaration section before use AT THE START OF THE FUNCTION AND BEFORE ANY STATEMENTS

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

What is the value of a variable if it has been declared but not been assigned a value?

A

Most compilers set the value to 0 and this zero is constant

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

What is a constant?

A

A constant is a variable whose value cannot be modified and is essentially read-only

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