Write a C++ program that has a declaration in main() to store the following numb
ID: 3852290 • Letter: W
Question
Write a C++ 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.8, and 10. There should be a function call to show() that accepts the rates array as a parameter and then displays the numbers in the array.
Format Manipulators: setw ( ), setprecision ( ), setiosflags(ios::showpoint), setiosflags(ios::fixed), setiosflags(ios::scientific), setiosflags(ios::left), setiosflags(ios::right).
Common Math Functions: abs(a), pow (a, b), sqrt (a), sin (a), tan (a), cos (a), log10(a), exp (a).
Escape Sequences: /b, /f, /n, /r, //, /', /"
Note: All variables must be declared properly before they can be displayed and the results should be copied to the program as a block comment. The program should display adequate information about the nature of the program and the calculated results.
Make sure:
(i) Follow “program template” guidelines for all required documentation and program description.
(ii) Be sure to copy/paste your test run output as a comment block inside your source code file.
(iii) Display the resulting product with 2 decimal place accuracy.
Explanation / Answer
#include<iostream.h>
#include<conio.h>
void show(double*); //function declaration
void main(){
double rates[8] = {6.5,7.2,7.5,8.3,8.6,9.4,9.8,10};//initialization of the array rates
show(rates);//calling function show by passing address of first element in rates
getch();
}
void show(double *rates){//receiving the addresss in rates(call by reference).
for(int i=0;i<8;i++)
cout<<rates[i]<<" ";
}
Related Questions
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.