Skip to main content
Brave Programmer Logo

BraveProgrammer

BraveProgrammer

HomeProjectsBlogsCoursesLessonsAbout

Site footer

BraveProgrammer

Free coding courses, practical tutorials, and real projects from BraveProgrammer. Learn web development with React, Next.js, and TypeScript.

Navigation

  • Home
  • Projects
  • Blogs
  • Courses

Resources

  • About
  • Lessons
  • Teach on BraveProgrammer

© 2026 BraveProgrammer. All rights reserved.

Pointer Arithmetic | C Programming Fundamentals lesson | BraveProgrammer
  1. Courses
  2. /
  3. C Programming Fundamentals

Lesson 14 of 50

·c

Pointer Arithmetic

10 mins

Course progress28%

What you'll learn

Keep these ideas in mind as you work through the lesson.

4 points
  • `p + n` moves the pointer `n` elements forward.
  • Subtracting two pointers yields the number of elements between them.
  • Pointer arithmetic outside the bounds of an array leads to **undefined behavior**.
  • `sizeof(*p)` tells you the size of the pointed‑to type.

When a pointer points to an element of an array, adding or subtracting integers moves it by that many elements, not bytes.

int arr[5] = {10,20,30,40,50};
int *p = arr;        // same as &arr[0]
printf("%d
", *(p+2)); // -> 30

The compiler automatically scales the offset by sizeof(*p). Pointer arithmetic is only defined within the same array (or one past the last element).

Make it stickPractice what you've learned1 quiz · 3 practical tests · Optional activities from C Programming FundamentalsBrowse activities
Previous lessonPointers – BasicsContinue to lesson 15ArraysBack to C Programming Fundamentals curriculum