Modify the show() function written in Exercise 1 to alter the address in rates. Always use the expression *rates rather than *(rates + i) to retrieve the correct element. This is the function "Write a program that has a declaration in main() to store the following numbers in an array named rates: 6.5, 7.2, 7.5, 8.3, 8.6, 9.4, 9.6, 9.8, and 10.0. Include a function call to show() that accepts rates in a parameter named rates and then displays the numbers by using the pointer notation *(rates + i)." written in Excerise 1
We need to use *(rates + i) notation to show the content of the array.
Here is the desired output
And here is the C code as requested
#include <stdio.h>
void show(float *rates)
{
for(int i=0;i<9;i++)
{
printf("%.1f\n",*(rates + i)); //.1 will round off float to 1 decimal place//
}
}
int main()
{
float rates[9] = {6.5, 7.2, 7.5, 8.3, 8.6, 9.4, 9.6, 9.8, 10.0};
show(rates);
return 0;
}
If you liked the solution, please give a positive rating to the answer. Your rating motivates experts to help other students also. Thank you :)
Get Answers For Free
Most questions answered within 1 hours.