Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

Please help with my c++ Write a program has a declaration in main () to store th

ID: 3684108 • Letter: P

Question

Please help with my c++ Write a program has a declaration in main () to store the following numbers into an array named rates: 6.5, 7.2, 7.5, 8.7, 8.6, 9.4, 9.6, 9.8, 10.6. There should be a function call to show () that accepts rates in a parameter argument named rates and then displays the numbers using the pointer notation * (rates + i); Modify the show () function written above to alter the address in rates. Always use the expression *rates rather than *(rates + i) to retrieve the correct element.

Explanation / Answer

Program1:

#include<iostream>
using namespace std;
void show(double *rates){
   for(int i=0;i<9;i++){
       cout<<" "<<*(rates+i);
   }
}

int main(){
   double rates[]={6.5,7.2,7.5,8.7,8.6,9.4,9.6,9.8,10.6};
   show(rates);
   return 0;  
}

Program2:


#include<iostream>
using namespace std;
void show(double *rates){
   for(int i=0;i<9;i++){
       cout<<" "<<*rates;
       rates++;
   }
}

int main(){
   double rates[]={6.5,7.2,7.5,8.7,8.6,9.4,9.6,9.8,10.6};
   show(rates);
   return 0;  
}