8. Consider the following code: #include #include using namespace std; const double E = 2.718; void...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
8. Consider the following code: #include <iostream> #include <cmath> using namespace std; const double E = 2.718; void computeExponential (const double inArr[], int size); int main() { } = double expArray 1[] = (3.14, 5.5, 16.1); double expArray2 [] = {3, 5.7}; double expArray 3 [] (7.14, 42.5, 16}; computeExponential (expArray1, 3); computeExponential (expArray2, 2); computeExponential (expArray3, 3); return 0; void computeExponential (const double inArr [], int size) { static int count = 0; for(int i = 0; i < size; i++) { } } cout << pow (E, inArr [i]) << endl; count++; cout<< This function has been called " << count << "times."<< endl; (a) (3 pts) Identify any global variables. How do you know they are global? (b) (3 pts) What is the difference between the two uses of const in this code? (c) (3 pts) What is the value of count at the end? Why? 8. Consider the following code: #include <iostream> #include <cmath> using namespace std; const double E = 2.718; void computeExponential (const double inArr[], int size); int main() { } = double expArray 1[] = (3.14, 5.5, 16.1); double expArray2 [] = {3, 5.7}; double expArray 3 [] (7.14, 42.5, 16}; computeExponential (expArray1, 3); computeExponential (expArray2, 2); computeExponential (expArray3, 3); return 0; void computeExponential (const double inArr [], int size) { static int count = 0; for(int i = 0; i < size; i++) { } } cout << pow (E, inArr [i]) << endl; count++; cout<< This function has been called " << count << "times."<< endl; (a) (3 pts) Identify any global variables. How do you know they are global? (b) (3 pts) What is the difference between the two uses of const in this code? (c) (3 pts) What is the value of count at the end? Why?
Expert Answer:
Answer rating: 100% (QA)
a Identify any global variables How do you know they are global There are two global variables in th... View the full answer
Related Book For
Data Structures and Algorithms in Java
ISBN: 978-1118771334
6th edition
Authors: Michael T. Goodrich, Roberto Tamassia, Michael H. Goldwasser
Posted Date:
Students also viewed these programming questions
-
123 Compare the purely graphical properties of these two notations, and the ways in which the graphical properties of each display correspond to the information structure being defined. Describe...
-
for the equality test for M and N. The question concerns how to represent multisets of strings within ML. For each of the given data representations (a), (b) and (c) describe how you would implement...
-
With the CARES Act costing over $2 trillion and the federal government facing a significant decline in tax revenue, explain the effectiveness of fiscal policy using the three claims outlined in the...
-
Contrast the hierarchical and decentralized methods of control.
-
1. The following information pertains to Kane Co.s defined benefit pension plan: Prepaid pension cost (net asset), January 1, 2009 . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . . $...
-
A certain wire has a circular cross section of radius \(R\) and carries a current \(I\). Suppose that the charge carriers all move along the cylindrical surface of the wire, not through its...
-
Cleaners, Inc., is switching to paying employees every 2 weeks rather than weekly and will therefore skip 1 weeks pay. The firm has 25 employees who work a 60- hour week and earn an average wage of...
-
Write one page about pipelining in smartphones that support Android operating systems. (10 marks)
-
Figure 9-26 illustrates a partial class diagram for a property management company. Using the data in the class diagram, create a database schema.
-
A project that would require an initial cash outflow of $340,000 at the begging is expected to produce cash inflows of $70,000 at the end of each projects 7 years. Assume the required return is 9%...
-
1.What fear tactics can we use to help people reduce plastic waste? 2. How can brands change their behavior in order to encourage their customers to use eco-friendly products? 3. What baby steps can...
-
Calculate the impulse from the below applied force versus time graph. () F(newtons) 3 2 2 4 6 8 - 1 (sec ) 10 8 N.S 13 N.S 11 N.S 10 N.S ()
-
You just purchased a share of SPCC for $101. You expect to receive a dividend of $5 in one year. If you expect the price after the dividend is paid to be $114, what total return will you have earned...
-
Analysis of the Industry-Activision Blizzard Strategic Group(s) in which the company exists and competitors in it/them. Intensity of rivalry among existing competitors (Use Porters 5 Forces for...
-
How Changes in Economic Conditions Could Potentially Affect the Funds and policies that direct the use of these funds. A change in the demand or need for the PMHC program or its services could affect...
-
Suppose the government in each province of country X sets the price of health care. a. Using the data in table 3.1 for Year 1 only, calculate the arc price elasticity of demand for visits to the...
-
Presented below are income statements prepared on a LIFO and FIFO basis for Kenseth Company, which started operations on January 1, 2024. The company presently uses the LIFO method of pricing its...
-
Let T be a tree with n positions. Define the lowest common ancestor (LCA) between two positions p and q as the lowest position in T that has both p and q as descendants (where we allow a position to...
-
Our implementation of shortestPathLengths in Code Fragment 14.13 relies on use of ?infinity? as a numeric value, to represent the distance bound for vertices that are not (yet) known to be reachable...
-
Anna has just won a contest that allows her to take n pieces of candy out of a candy store for free. Anna is old enough to realize that some candy is expensive, while other candy is relatively cheap,...
-
Assume you want to use random tests on an FIR filter program. How would you know when the program under test is executing correctly?
-
Three devices are attached to a microprocessor: Device 1 has highest priority and device 3 has lowest priority. Each devices interrupt handler takes 5 time units to execute. Show what interrupt...
-
Provide examples of how each of the following can occur in a typical program: a. compulsory miss b. capacity miss c. conflict miss
Study smarter with the SolutionInn App