wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Challenge

Total questions: 10

Worksheet time: 5mins

Name
Class
Date
1.

What is a pointer in C?

a)

A pointer is a variable that holds the address of another variable in C.

b)

A pointer is a constant value in C.

c)

A pointer is a type of function in C.

d)

A pointer is a data structure in C.

2.

How do you declare a pointer variable?

a)

int *ptr;

b)

int ptr*;

c)

char ptr*;

d)

float *ptr;

3.

What is the purpose of the 'NULL' pointer?

a)

The 'NULL' pointer is used to store a memory address for future use.

b)

The purpose of the 'NULL' pointer is to indicate that a pointer does not point to any valid memory location.

c)

The 'NULL' pointer serves as a placeholder for uninitialized variables.

d)

The 'NULL' pointer indicates a pointer that points to the last allocated memory.

4.

Explain the difference between a pointer and an array in C.

a)

A pointer is a type of array, while an array is a pointer to a single element.

b)

A pointer holds a memory address, while an array is a fixed-size collection of elements.

c)

A pointer stores data directly, while an array only holds addresses of data.

d)

An array can change size dynamically, while a pointer is always fixed in size.

5.

What is dynamic memory allocation in C?

a)

Dynamic memory allocation in C is the process of defining fixed memory sizes at compile time.

b)

Dynamic memory allocation in C is the technique of using pointers to access static memory.

c)

Dynamic memory allocation in C is the process of allocating memory during program execution using functions like malloc and free.

d)

Dynamic memory allocation in C is the use of global variables to manage memory.

6.

How do you create a linked list in C?

a)

Define a struct for the node, initialize head to NULL, and implement functions for list operations.

b)

Implement a queue structure instead of a linked list.

c)

Create a class for the node and use pointers for connections.

d)

Use an array to store elements and manage size manually.

7.

What is a structure in C and how is it defined?

a)

A structure in C is declared using the 'struct' keyword, followed by the structure name and its properties in angle brackets.

b)

A structure in C is defined using the 'struct' keyword, followed by the structure name and its members enclosed in braces.

c)

A structure in C is created using the 'class' keyword, followed by the class name and its attributes in parentheses.

d)

A structure in C is defined with the 'define' keyword, followed by the structure name and its fields in brackets.

8.

How do you access members of a structure using a pointer?

a)

Use the asterisk operator (*) to dereference the pointer.

b)

Access members directly without using any operator.

c)

Use the arrow operator (->) to access members of a structure via a pointer.

d)

Use the dot operator (.) to access members of a structure via a pointer.

9.

What is the difference between a stack and a heap?

a)

A stack is LIFO and used for static allocation; a heap is for dynamic allocation and allows arbitrary order.

b)

A stack is used for both static and dynamic allocation; a heap is only for temporary storage and follows LIFO.

c)

A stack is FIFO and used for dynamic allocation; a heap is for static allocation and follows a strict order.

d)

A stack is for dynamic allocation and allows random access; a heap is LIFO and used for static allocation.

10.

Explain the concept of a function pointer in C.

a)

A function pointer is a variable that holds the address of a function, enabling dynamic function calls and callbacks.

b)

A function pointer is a type of variable that stores integer values for calculations.

c)

A function pointer is a special kind of array that holds multiple function definitions.

d)

A function pointer is a reference to a variable that can only store string data.