fastread homefastrread library fastread menu

C++ : Access Elements of an Array Using Pointer

Tutorial by:Manisha Dubey      Date: 2016-06-18 04:56:50

❰ Previous Next ❱

This program declares the array of five element and the elements of that array are accessed using pointer.

Source Code to Access Array Elements Using Pointer


#include <iostream>
using namespace std;
int main(){
   int data[5], i;
   cout << "Enter elements: ";
   for(i=0;i<5;++i)
      cin >> data[i];
   cout << "You entered: ";
   for(i=0;i<5;++i)
      cout << endl << *(data+i);
   return 0;
}

Output

Enter elements: 1
2
3
5
4
You entered: 1
2
3
5
4

❰ Previous Next ❱


C++

Submit Your Thought, Tutorial, Articls etc.

Submit Your Information India's Number one online promotion website