Answer to Question #313508 in C++ for Hassan

Question #313508

Declare a float array of length 15 fArray.

. Input the values of fArray from user.

• Display the values of odd indexes using pointer arithmetic only.


1
Expert's answer
2022-03-17T17:09:59-0400
#include <iostream>

using namespace std;

int main()
{
	float arr[15];
	cout << "Please, enter a float elements of array: " << endl;
	for (int i = 0; i < 15; i++)
	{
		cout << "Enter a value of array[" << i << "]: ";
		cin >> arr[i];
	}
	//Display the values of odd indexes using pointer arithmetic only
	for (float* pf = &arr[1]; pf!=&arr[15]; pf+=2)
	{
		cout << *pf<<" ";
	}
}

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