0
0
Cprogramming~5 mins

Pointer declaration - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is a pointer in C?
A pointer is a variable that stores the memory address of another variable.
Click to reveal answer
beginner
How do you declare a pointer to an integer in C?
Use the syntax: int *ptr; where ptr is a pointer to an integer.
Click to reveal answer
beginner
What does the asterisk (*) mean in a pointer declaration?
The asterisk (*) indicates that the variable is a pointer to the type specified before it.
Click to reveal answer
intermediate
Explain the difference between int *ptr; and int* ptr;.
Both declare a pointer to an int. The placement of * does not change the meaning; it's a style choice.
Click to reveal answer
intermediate
What happens if you declare a pointer but do not initialize it?
The pointer contains a garbage address and using it without initialization can cause errors or crashes.
Click to reveal answer
Which of the following declares a pointer to a float?
Afloat *ptr;
Bfloat ptr*;
C*float ptr;
Dptr float*;
What does the pointer variable store?
AThe value of another variable
BThe memory address of another variable
CThe size of a variable
DThe type of a variable
How do you declare a pointer to a character?
Aptr char*;
Bchar ptr*;
C*char ptr;
Dchar* ptr;
What is wrong with this declaration? int ptr;
AIt declares an integer variable, not a pointer
BIt declares a pointer to a pointer
CIt declares a pointer correctly
DIt declares a pointer to a float
Which symbol is used to declare a pointer variable?
A#
B&
C*
D$
Describe how to declare a pointer to an integer and explain what it stores.
Think about how you tell the computer to hold an address instead of a value.
You got /3 concepts.
    Explain why it is important to initialize a pointer before using it.
    Imagine using a map with a wrong address.
    You got /3 concepts.