Declare a double array of length 13 dArray.
• Input the values of dArray from user.
• Display the values of even indexes using pointer arithmetic only.
#include<iostream>
using namespace std;
int main()
{
	double dArray[13];
	double *p;
	p=dArray;
	 for ( int i = 0; i<13; i++ )
	 if(i%2==0)
	 {
	 	std::cout << "*(p + " << i << ") = " << *(p + i) << std::endl;
	 
    	        cin >> dArray[i];
    	       
  	}
  	for (int j = 0; j < 13; j++ )
     if(j%2==0)
  	{
  		
		       std::cout << "*(p + " << j << ") = " << *(p + j) << std::endl;
    	       cout << "n[" << j << "] = " << dArray[j] << endl;		   
  	}
  	return 0;
}
Comments