- Declaring, initializing, and dereferencing pointers safely
- Passing pointers to functions to modify caller-side variables
- Pointer arithmetic on arrays and strings
- Writing swap routines for values, array elements, and strings
- Implementing linear and binary search with pointer-based access
- Dynamic memory allocation with
malloc,calloc, andfree - Reversing, concatenating, comparing, and copying strings without library functions
- Inserting and deleting array elements using pointer manipulation
- Digit-level operations: sum, reversal, palindrome check, factorial
Pointers are the most powerful — and most misunderstood — feature of the C language. The only way to truly master them is through deliberate practice. This page collects 30 pointer assignments, arranged from foundational concepts to advanced function-based operations. Every assignment links to a full tutorial with the program code, sample output, and a line-by-line explanation.
🔹 Basic Pointer Concepts
Start here — declare, dereference, and swap values through pointers.
- 1. Write a program in C to demonstrate the basic concept of pointers by declaring and dereferencing a pointer variable.
- 2. Write a program in C to swap two numbers using pointers.
🔹 Arrays & Pointers
Traverse, sum, reverse, search, and manipulate arrays through pointer arithmetic.
- 3. Write a program in C language to find the sum of elements in an array using pointers.
- 4. Write a program in C language to reverse an array using pointers.
- 9. Write a program in C to implement linear search in an array using pointers.
- 10. Write a program in C programming to implement binary search in a sorted array using pointers.
- 15. Write a program in C language to implement a function to swap two elements in an array using pointers.
- 16. Write a program in C language to implement a function to find the maximum element in an array using pointers.
- 17. Write a program in C to implement a function to find the minimum element in an array using pointers.
- 18. Write a program in C to implement a function to sort an array using pointers.
🔹 Strings & Pointers
Implement classic string operations from scratch using only pointer traversal.
- 5. Write a program in C language to find the length of a string using pointers.
- 6. Write a program in C to concatenate two strings using pointers.
- 7. Write a program in C to compare two strings using pointers.
- 8. Write a program in C to copy one string to another using pointers.
- 19. Write a program in C language to implement a function to reverse a string using pointers.
- 20. Write a program to implement a function to concatenate two strings using pointers.
- 21. Write a program in C to implement a function to copy one string to another using pointers.
- 22. Write a program in C language to implement a function to compare two strings using pointers.
- 23. Write a program to implement a function to calculate the length of a string using pointers.
- 30. Write a program in C programming to implement a function to swap two strings using pointers.
🔹 Dynamic Memory Allocation
Allocate, use, and free heap memory safely with pointer-based access.
- 11. Write a program in C language to dynamically allocate memory for an integer variable using pointers.
- 12. Write a program in C to dynamically allocate memory for an array using pointers.
- 13. Write a program in C language to dynamically allocate memory for a string using pointers.
- 14. Write a program in C to free dynamically allocated memory using pointers.
🔹 Functions with Pointers
Design functions that modify caller state, compute digit-level results, or insert/delete array elements.
- 24. Write a program in C to implement a function to insert an element into an array at a specified position using pointers.
- 25. Write a program to implement a function to delete an element from an array at a specified position using pointers.
- 26. Write a program to implement a function to find the sum of digits of a number using pointers.
- 27. Write a program in C to implement a function to reverse a number using pointers.
- 28. Write a program in C to implement a function to check if a number is palindrome using pointers.
- 29. Write a program in C language to implement a function to find the factorial of a number using pointers.
How to Get the Most Out of These Assignments
Reading a solution is not the same as writing one. For each assignment, follow this three-step workflow:
- Attempt first. Open a blank editor and try to solve the problem using only the assignment description. Even if you get stuck, the act of trying cements the concept.
- Compare carefully. Open the solution page and compare your approach to the reference. Look for differences in pointer arithmetic, edge cases, and memory management.
- Re-implement from scratch. Close the solution page and write the program again without looking. This is the step most learners skip — and it's the one that actually builds fluency.
💡 Tip: Compile with gcc -Wall -Wextra -std=c11 -g so the compiler flags misuse of pointers. Run each program under valgrind when dynamic allocation is involved to catch memory leaks early.