#include<iostream>
#include<string>
using namespace std;
int main()
{
int arr[5] = { 2,3,4,5,9 };
int *p;
p = arr;
cout << "Traversing array through the pointer index: " << endl;
for (int i = 0; i < 5; ++i) {
cout << *(p + i) << " , ";
}
cout << endl << "Traversing Through the pointer : " << endl;
for (int i = 0; i < 5; ++i) {
cout << *p << " , ";
p++;
}
cout << endl << "Traversing array using array as pointer : " << endl;
for (int i = 0; i < 5; ++i) {
cout << *(arr + i) << " , ";
}
cout << endl;
system("pause");
return 0;
}
No comments:
Post a Comment