WorksheetsC Programming Challenge
Total questions: 10
Worksheet time: 5mins
What is a pointer in C?
A pointer is a variable that holds the address of another variable in C.
A pointer is a constant value in C.
A pointer is a type of function in C.
A pointer is a data structure in C.
How do you declare a pointer variable?
int *ptr;
int ptr*;
char ptr*;
float *ptr;
What is the purpose of the 'NULL' pointer?
The 'NULL' pointer is used to store a memory address for future use.
The purpose of the 'NULL' pointer is to indicate that a pointer does not point to any valid memory location.
The 'NULL' pointer serves as a placeholder for uninitialized variables.
The 'NULL' pointer indicates a pointer that points to the last allocated memory.
Explain the difference between a pointer and an array in C.
A pointer is a type of array, while an array is a pointer to a single element.
A pointer holds a memory address, while an array is a fixed-size collection of elements.
A pointer stores data directly, while an array only holds addresses of data.
An array can change size dynamically, while a pointer is always fixed in size.
What is dynamic memory allocation in C?
Dynamic memory allocation in C is the process of defining fixed memory sizes at compile time.
Dynamic memory allocation in C is the technique of using pointers to access static memory.
Dynamic memory allocation in C is the process of allocating memory during program execution using functions like malloc and free.
Dynamic memory allocation in C is the use of global variables to manage memory.
How do you create a linked list in C?
Define a struct for the node, initialize head to NULL, and implement functions for list operations.
Implement a queue structure instead of a linked list.
Create a class for the node and use pointers for connections.
Use an array to store elements and manage size manually.
What is a structure in C and how is it defined?
A structure in C is declared using the 'struct' keyword, followed by the structure name and its properties in angle brackets.
A structure in C is defined using the 'struct' keyword, followed by the structure name and its members enclosed in braces.
A structure in C is created using the 'class' keyword, followed by the class name and its attributes in parentheses.
A structure in C is defined with the 'define' keyword, followed by the structure name and its fields in brackets.
How do you access members of a structure using a pointer?
Use the asterisk operator (*) to dereference the pointer.
Access members directly without using any operator.
Use the arrow operator (->) to access members of a structure via a pointer.
Use the dot operator (.) to access members of a structure via a pointer.
What is the difference between a stack and a heap?
A stack is LIFO and used for static allocation; a heap is for dynamic allocation and allows arbitrary order.
A stack is used for both static and dynamic allocation; a heap is only for temporary storage and follows LIFO.
A stack is FIFO and used for dynamic allocation; a heap is for static allocation and follows a strict order.
A stack is for dynamic allocation and allows random access; a heap is LIFO and used for static allocation.
Explain the concept of a function pointer in C.
A function pointer is a variable that holds the address of a function, enabling dynamic function calls and callbacks.
A function pointer is a type of variable that stores integer values for calculations.
A function pointer is a special kind of array that holds multiple function definitions.
A function pointer is a reference to a variable that can only store string data.
