C++ program to print elements of an array using pointers.
C++ Program to print elements of an array using pointer
#include <iostream> using namespace std; int main(){ int array[100], num, i; cout << "Enter Number of elements\n"; cin >> num; cout << "Enter " << num << " Integers\n"; for(i = 0; i < num; ++i){ cin >> array[i]; } cout << "Array Content\n"; for(i = 0; i < num; ++i){ cout << *(array+i) << " "; } return 0; }Output
Enter Number of elements 6 Enter 6 Integers 7 3 2 5 9 1 Array Content Enter 6 Integers 7 3 2 5 9 1
Recommended Posts