I'm trying to figure out a program that uses pointer notation to display numbers in an array. I have to use the pointer notation *arrayname.
This is what I have to do: Modify the show() function to alter the address in rates. Use the expression *rates rather than *(rates + i) to retrieve the correct element.
#include <iostream>
#include <iomanip>
usingnamespace std;
void show(float[]);
int main()
{
float rates[9] = {6.5, 7.2, 7.5, 8.3, 8.6, 9.4, 9.6, 9.8, 10.0}; //declaring array
cout << "The numbers are: " << endl;
show(rates); //calls function
getchar();
getchar();
return 0;
}
void show(float rates[])
{
int i;
for (i=0;i<9;i++) //uses a for loop along with pointer notation to print the number for each element
{
rates[i] = *(rates + i); // I know this doesnt do much
cout << rates[i] << " ";
}
return;
}