C PROGRAMMING PRACTICAL FILE
Name: Your Name
Branch: Your Branch (CSE/IT/etc.)
Subject: C Programming
Practical No: 2
Title: Pointer and Multi-Level Pointer Program
Aim
To study and implement pointers, double pointers, and triple pointers in C.
Theory
A pointer is a variable that stores the address of another variable.
A single pointer stores the address of a variable.
A double pointer stores the address of a pointer.
A triple pointer stores the address of a double pointer.
These are useful for dynamic memory allocation and complex data structures.
Program 1: Pointer Example
#include <stdio.h>
void main()
int a = 10;
int *ptr;
ptr = &a;
printf("Value of a = %d\n", a);
printf("Address of a = %u\n", &a);
printf("Pointer ptr stores address = %u\n", ptr);
printf("Value of a using pointer = %d\n", *ptr);
Output
Value of a = 10
Address of a = (some memory address)
Pointer ptr stores address = (same address)
Value of a using pointer = 10
Explanation
ptr = &a stores the address of variable a
*ptr gives the value stored at that address
Program 2: Multi-Level Pointer Example
#include <stdio.h>
void main()
int ***r, **q, *p, i = 5;
p = &i;
q = &p;
r = &q;
printf("%d %d %d", *p, **q, ***r);
Output
555
Explanation
*p gives value of i
**q accesses p then i
***r accesses q → p → i
All print the same value.
Conclusion
Pointers and multi-level pointers allow indirect access to variables and are very important in C
programming for memory handling and efficient coding.