Answer to Question #237747 in C++ for scada HMI

Question #237747

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.


1
Expert's answer
2021-09-15T23:40:14-0400
#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;
}

Need a fast expert's response?

Submit order

and get a quick answer at the best price

for any assignment or question with DETAILED EXPLANATIONS!

Comments

No comments. Be the first!

Leave a comment

LATEST TUTORIALS
New on Blog
APPROVED BY CLIENTS