Pointer programming exercises and solutions in C

Pointer is a variable that stores memory addresses. Unlike normal variables it does not store user given or processed value, instead it stores valid computer memory address.

Pointer allows various magical things to be performed in C.

  • Pointers are more efficient in handling arrays and structures.
  • Pointers are used to return multiple values from a function.
  • Pointer allows dynamic memory allocation and deallocation (creation and deletion of variables at runtime) in C. Which undoubtedly is the biggest advantage of pointers.
  • Pointer allows to refer and pass a function as a parameter to functions.

and many more...

For beginners pointers can be a bad dream if not practiced well. However, once mastered you can do anything you want to do in C programming language.

In this exercise I will cover most of the pointer related topics from a beginner level. Always feel free to drop your queries and suggestion down below in the comments section.

Pointer to Pointer (Double pointer) memory representation
Pointer to Pointer (Double pointer) memory representation

Required knowledge

Pointers, Pointer Arithmetic, Pointer to Pointer, Pointer and Arrays, Function Pointer

Please go through above tutorials to get a good grasp of following examples.

List of pointer programming exercises

  1. Write a C program to create, initialize and use pointers.
  2. Write a C program to add two numbers using pointers.
  3. Write a C program to swap two numbers using pointers.
  4. Write a C program to input and print array elements using pointer.
  5. Write a C program to copy one array to another using pointers.
  6. Write a C program to swap two arrays using pointers.
  7. Write a C program to reverse an array using pointers.
  8. Write a C program to search an element in array using pointers.
  9. Write a C program to access two dimensional array using pointers.
  10. Write a C program to add two matrix using pointers.
  11. Write a C program to multiply two matrix using pointers.
  12. Write a C program to find length of string using pointers.
  13. Write a C program to copy one string to another using pointers.
  14. Write a C program to concatenate two strings using pointers.
  15. Write a C program to compare two strings using pointers.
  16. Write a C program to find reverse of a string using pointers.
  17. Write a C program to sort array using pointers.
  18. Write a C program to return multiple value from function using pointers.

About Pankaj

Blogger, Programmer, developer, music lover, and learner. I started this blog to share a bit of knowledge what I have to the world.

Comments and discussion
Have a doubt, write here. I will help my best.
Before commenting you must escape your source code before commenting. Paste your source code inside
<pre><code> ----Your Source Code---- </code></pre>