Function scale multiples its first argument (a real number) by 10 raised to the power indicated by its second argument (an integer). For example, the function call scale (2.5, 2) Returns the value 250.0 (2.5 x 102). The function call scale (2.5, -2) Return the value 0.025 (2.5 x 10²) Write only the main function, create and initialize a double array and then call the function scale for each elements of the array. At the end, the contents of the array must consist of scaled values. Create and use a separate integer array as the powers of each corresponding value. Eg. If double array has the following contents: 1.0 2.0 3.0 4.0 and the Integer array of powers have the following: double scale (double x, int n) double scale_factor; scale factor - pow (10, n) ; return x*scale_factor; 4 3 2 After function calls, the new contents of the double array must be updated as in seen in the following: 1.0x10 2.0x10³ 3.0x102 4.0x10²

C++ Programming: From Problem Analysis to Program Design
8th Edition
ISBN:9781337102087
Author:D. S. Malik
Publisher:D. S. Malik
Chapter6: User-defined Functions
Section: Chapter Questions
Problem 19PE
icon
Related questions
Question
Function scale multiples its first argument (a real number) by 10 raised to the power indicated
by its second argument (an integer). For example, the function call
scale (2.5, 2)
double scale (double x, int n)
double scale_factor;
scale factor - pow (10, n);
return x*scale_factor;
Returns the value 250.0 (2.5 x 102). The function call
scale (2.5, -2)
Return the value 0.025 (2.5 x 10²)
Write only the main function, create and initialize a double array and then call the function
scale for each elements of the array. At the end, the contents of the array must consist of
scaled values. Create and use a separate integer array as the powers of each corresponding
value.
Eg. If double array has the following contents:
1.0 2.0 3.0 4.0 and the
Integer array of powers have the following:
4 3. 2 -2,
After function calls, the new contents of the double array must be updated as in seen in the
following:
1.0x104 2.0x10³ 3.0x10² 4.0x10²
Transcribed Image Text:Function scale multiples its first argument (a real number) by 10 raised to the power indicated by its second argument (an integer). For example, the function call scale (2.5, 2) double scale (double x, int n) double scale_factor; scale factor - pow (10, n); return x*scale_factor; Returns the value 250.0 (2.5 x 102). The function call scale (2.5, -2) Return the value 0.025 (2.5 x 10²) Write only the main function, create and initialize a double array and then call the function scale for each elements of the array. At the end, the contents of the array must consist of scaled values. Create and use a separate integer array as the powers of each corresponding value. Eg. If double array has the following contents: 1.0 2.0 3.0 4.0 and the Integer array of powers have the following: 4 3. 2 -2, After function calls, the new contents of the double array must be updated as in seen in the following: 1.0x104 2.0x10³ 3.0x10² 4.0x10²
Expert Solution
steps

Step by step

Solved in 4 steps with 2 images

Blurred answer
Knowledge Booster
Array
Learn more about
Need a deep-dive on the concept behind this application? Look no further. Learn more about this topic, computer-science and related others by exploring similar questions and additional content below.
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
C++ Programming: From Problem Analysis to Program…
C++ Programming: From Problem Analysis to Program…
Computer Science
ISBN:
9781337102087
Author:
D. S. Malik
Publisher:
Cengage Learning
C++ for Engineers and Scientists
C++ for Engineers and Scientists
Computer Science
ISBN:
9781133187844
Author:
Bronson, Gary J.
Publisher:
Course Technology Ptr