Back to C Programming
🖨️C Programming

Pointers in C Beginner Notes

Pointer basics, pointer arithmetic, pointers with arrays/strings, double pointers, and void pointers.

BeginnerIntermediateAdvanced

Pointers in C — Detailed Notes

Pointers in C is an important chapter in C Programming and is frequently tested in both conceptual and application-based questions. Students should first understand the core definition, then connect the topic with real-life observations and exam patterns.

A pointer in C is a variable that stores the memory address of another variable, enabling direct memory manipulation and efficient passing of data. In school and entrance exams, questions usually check your conceptual clarity, step-wise logic, and ability to avoid common mistakes.

To prepare effectively, break Pointers in C into smaller sub-parts: definition, laws/rules, examples, formulas, and revision questions. After theory, solve short questions, then move to mixed-level numericals or application prompts.

A smart revision strategy is to maintain a one-page summary for Pointers in C. Include important terms, two solved examples, and last-minute checkpoints before exams.

Key Exam Points

  • Pointer declaration: `int *ptr;` — stores address of an int variable.
  • `&` (address-of operator): `ptr = &var;` — assigns address of `var` to `ptr`.
  • `*` (dereference operator): `*ptr` accesses the value at the stored address.
  • Pointer arithmetic: `ptr++` moves to next element (increments by `sizeof(type)`).
  • NULL pointer: `int *ptr = NULL;` — initialise pointers to NULL to avoid undefined behaviour.
  • Function pointers, double pointers, pointers to arrays are advanced pointer concepts.

What You Will Learn in Pointers in C

A pointer in C is a variable that stores the memory address of another variable, enabling direct memory manipulation and efficient passing of data.

  • Pointer declaration: `int *ptr;` — stores address of an int variable.
  • `&` (address-of operator): `ptr = &var;` — assigns address of `var` to `ptr`.
  • `*` (dereference operator): `*ptr` accesses the value at the stored address.
  • Pointer arithmetic: `ptr++` moves to next element (increments by `sizeof(type)`).
  • NULL pointer: `int *ptr = NULL;` — initialise pointers to NULL to avoid undefined behaviour.
  • Function pointers, double pointers, pointers to arrays are advanced pointer concepts.

Syntax

int var = 10;
int *ptr = &var;   // ptr holds address of var

printf("%d", var);    // 10
printf("%p", ptr);    // address (e.g., 0x7ffd...)
printf("%d", *ptr);   // 10 (dereference)

*ptr = 20;            // change var through pointer
printf("%d", var);    // 20

Complete Code Example

#include <stdio.h>
void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}
int main() {
    int x = 5, y = 10;
    printf("Before: x=%d, y=%d\n", x, y);
    swap(&x, &y);
    printf("After: x=%d, y=%d\n", x, y);
    // Before: x=5, y=10
    // After: x=10, y=5

    // Pointer arithmetic
    int arr[] = {10, 20, 30};
    int *p = arr;
    for (int i = 0; i < 3; i++)
        printf("%d ", *(p + i));  // 10 20 30
    return 0;
}

Example

`int *p = &x;` makes `p` point to `x`; `(*p)++` increments `x` through the pointer.

Expected Exam Questions — Pointers in C

Q1.What is the difference between `*ptr` and `&var`?
Answer: `&var` is the address-of operator — gives the memory address of `var`. `*ptr` is the dereference operator — gives the value stored at the address in `ptr`. They are inverses: if `ptr = &var`, then `*ptr == var`.
Q2.What is a dangling pointer?
Answer: A dangling pointer points to memory that has been freed (deallocated) or has gone out of scope. Accessing it causes undefined behaviour. Fix: set pointer to NULL after free: `free(ptr); ptr = NULL;`.
Q3.What is the difference between call-by-value and call-by-reference in C?
Answer: Call-by-value: copies the value — changes in function don't affect original. Call-by-reference (using pointers): passes address — changes affect original variable. `void swap(int *a, int *b)` is call-by-reference via pointers.

🔘 MCQ Practice — Pointers in C

MCQ 1.What does `int *p = &x;` declare?
A. p is an int with value x
B. p is a pointer holding the address of x
C. p is a double pointer
D. p holds the value of x

✓ Correct Answer: p is a pointer holding the address of x

Download Pointers in C PDF Notes

Get the complete Pointers in C notes as a PDF — free for enrolled students, or browse our public study materials library.

More C Programming Topics

Related Subjects

Frequently Asked Questions — Pointers in C

What is Pointers in C in C Programming?
A pointer in C is a variable that stores the memory address of another variable, enabling direct memory manipulation and efficient passing of data.
What is the difference between `*ptr` and `&var`?
`&var` is the address-of operator — gives the memory address of `var`. `*ptr` is the dereference operator — gives the value stored at the address in `ptr`. They are inverses: if `ptr = &var`, then `*ptr == var`.
What is a dangling pointer?
A dangling pointer points to memory that has been freed (deallocated) or has gone out of scope. Accessing it causes undefined behaviour. Fix: set pointer to NULL after free: `free(ptr); ptr = NULL;`.
What is the difference between call-by-value and call-by-reference in C?
Call-by-value: copies the value — changes in function don't affect original. Call-by-reference (using pointers): passes address — changes affect original variable. `void swap(int *a, int *b)` is call-by-reference via pointers.
How do I prepare Pointers in C for exams?
To master Pointers in C, start by reading the theory carefully, then go through solved examples step by step. Practice numericals (if applicable), revise key formulas, and attempt previous year questions. SII notes cover all these aspects in a structured manner.
Are these Pointers in C notes free?
Yes! SII provides free access to Pointers in C notes and introductory study materials. Enrolled students get full access to detailed notes, solved papers, and live doubt-clearing sessions.
Which exams ask questions from Pointers in C?
Pointers in C is an important topic tested in Beginner, Intermediate, Advanced board exams, as well as University Semester Exams. It frequently appears in both short-answer and long-answer sections.