BeginnersBook

  • Home
  • Java
    • Java OOPs
    • Java Collections
    • Java Examples
  • C
    • C Examples
  • C++
    • C++ Examples
  • DBMS
  • Computer Network
  • Python
    • Python Examples
  • More…
    • jQuery
    • Kotlin
    • WordPress
    • SEO
    • JSON
    • JSP
    • JSTL
    • Servlet
    • MongoDB
    • XML
    • Perl

C Program to Access Array Elements Using Pointer

Last Updated: July 25, 2022 by Chaitanya Singh | Filed Under: C Programs

In this C program, you will learn how to access array elements using pointer.

Program to access array elements using pointer

In this program, we have an array of integers, the name of the array is numbers. In pointer notation, numbers[0] is equivalent to *numbers. This is because the array name represents the base address (address of first element) of the array.

We already learned in pointer tutorial that * before an address give us the value stored at that address, thus we can say *numbers is equivalent to the numbers[0]. Similarly *(numbers+1) is equivalent to numbers[1] and so on. This logic is used in this program access and print the array elements.

#include <stdio.h>
int main() {
  int numbers[5], n=0;

  printf("How many elements you would like to enter?: ");
  scanf("%d",&n);
  printf("Enter elements: ");
  for (int i = 0; i < n; ++i)
    scanf("%d", numbers + i);

  printf("Entered elements: \n");
  for (int i = 0; i < n; ++i)
    printf("%d\n", *(numbers + i));
  return 0;
}

Output:
C Program to Access Array Elements Using Pointer

Related C Examples:

  • C Program to find the frequency of characters in a string
  • C Program to find the largest of three numbers using pointers
  • C Program to count vowels and consonants in a string using pointer
  • C Program to print string using pointer
❮ C TutorialC Programs ❯

Top Related Articles:

  1. C Program to Calculate Average Using Array
  2. C Program to concatenate two strings without using strcat
  3. C Program to find greatest of three numbers
  4. C Program to Print String using Pointer
  5. C Program to swap first and last digit of a number

About the Author

I have 15 years of experience in the IT industry, working with renowned multinational corporations. Additionally, I have dedicated over a decade to teaching, allowing me to refine my skills in delivering information in a simple and easily understandable manner.

– Chaitanya

Copyright © 2012 – 2025 BeginnersBook . Privacy Policy . Sitemap