Lesson 20 of 23

Pointers and Arrays

10 min 35 XP

An array's name is the address of its first element, so a[i] is the same as *(a + i). p++ moves to the next element (4 bytes ahead for an int).

Example: edit me and press Run

Output Loading C (first time takes a few seconds)
Press Run to see the result here.

Challenge

+35 XP

Read n and n numbers. Reverse the array in place using only pointers (no a[i]; use *(a + i) or p++), then print it. Input: 5 1 2 3 4 5 Output: 5 4 3 2 1

Output Loading C (first time takes a few seconds)
Press Run to see the result here.