C Programming Practice Test: Pointers and Arrays in C — Flashcards | C Programming | FatSkills

C Programming Practice Test: Pointers and Arrays in C — Flashcards

Fast review mode: answers are shown by default so you can skim quickly. Hide them if you want to self-test.

Pointers and Arrays in C quiz on: Pointers and addresses, function arguments, arrays, address arithmetic, character pointers and functions, multidimensional arrays, pointer arrays initialization, command line arguments and complicated declarations.

Arrays: Arrays are used to store multiple elements of the same data type in a contiguous block of memory. The index of an array represents the position of an element, starting from 0. Arrays are static, which means that their size is fixed once they are declared.
Pointers: Pointers are variables that store the address of another variable or array element. Pointers are dynamic, which means that they can be resized during runtime using dynamic memory allocation techniques. Pointers can be used to access array elements, pass arrays as function arguments, and implement dynamic data structures such as linked lists and trees.
Relationship between Arrays and Pointers: The name of an array in C is a pointer to the first element of the array. This means that you can use pointers to access array elements. 

You can also use pointers to pass arrays as function arguments. 

Arrays of Pointers: An array of pointers is an array that stores pointers to other variables or array elements. Arrays of pointers can be used to implement dynamic data structures such as linked lists and trees.
Pointers to Arrays: A pointer to an array is a pointer that points to the first element of an array. Pointers to arrays can be used to pass arrays as function arguments and to implement dynamic data structures such as linked lists and trees.

Arrays and pointers are powerful tools that can be used to write efficient and flexible C programs. By understanding the relationship between arrays and pointers, you can use them to implement a wide variety of data structures and algorithms.

1 of 184 Ready
What will be the output of the following C code?
#include <stdio.h>
int main()
{
char *p = NULL;
char *q = 0;
if (p)
printf(" p ");
else
printf("nullp");
if (q)
printf("q\n");
else
printf(" nullq\n");
}
nullp nullq
Shortcuts
Prev Space Show / hide Next
Turn this into a study set.
Sign in with Google to save tricky questions to your reminder list and resume on any device.
Sign in with Google Free • no extra password