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.
#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<<" ";
}
}
Comments
Leave a comment