Specifications:
define the specifications
Make sure you show your implementation of the use of arrays (or vectors) and pointers
C++ code:
#include<iostream>
using namespace std;
int main()
{
int a[100],n;
int *p=&a[0];
cout<<"Enter how many elements in array: ";
cin>>n;
cout<<"Enter arrray elements:";
for(int i=0;i<n;i++)//input array elements using pointer
{
cin>>*(p+i);
}
cout<<endl<<"array elements are:";
for(int i=0;i<n;i++)//printing array elements using pointer
{
cout<<*(p+i)<<" ";
}
int sum=0;
//sum using pointer
for(int i=0;i<n;i++)
{
sum+=*(p+i);
}
cout<<endl<<"Sum of array elements:"<<sum<<endl;
}
output:

Code In c++ Identify a problem that can efficiently be solved with the use of arrays...