(a) Write an int function called power (int n, int r) to calculate n to the...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
(a) Write an int function called power (int n, int r) to calculate n to the power of ri.e. n. For example, if n = 3 and r=4, it should return 3* = 81. (b) Write the main program and by calling the function you wrote in (a) display the first 10 powers of 2 until 4 in different lines, i.e. 48 3 9 27 234 185 616 16 81 16 64 256 32 243 1024 64 729 4096 128 2187 16384 256 512 6561 19683 65536 262144 1024 59049 1048576 (a) Write an int function called power (int n, int r) to calculate n to the power of ri.e. n. For example, if n = 3 and r=4, it should return 3* = 81. (b) Write the main program and by calling the function you wrote in (a) display the first 10 powers of 2 until 4 in different lines, i.e. 48 3 9 27 234 185 616 16 81 16 64 256 32 243 1024 64 729 4096 128 2187 16384 256 512 6561 19683 65536 262144 1024 59049 1048576
Expert Answer:
Answer rating: 100% (QA)
Certainly Heres a C program that includes the requested power function and displays ... View the full answer
Related Book For
Posted Date:
Students also viewed these programming questions
-
The following additional information is available for the Dr. Ivan and Irene Incisor family from Chapters 1-5. Ivan's grandfather died and left a portfolio of municipal bonds. In 2012, they pay Ivan...
-
Use the attached "words.txt" file to store the words along with their ranks in an AVL tree. Then provide the user the option to search for any word. If the word exists the program displays the rank...
-
Fill in each blank so that the resulting statement is true. I find (f g)(x) by replacing each occurrence of x in the equation for_______ with________ .
-
To learn more about careers in sales, go to www.bls.gov/oco/, the website for the Bureau of Labor Statistics. This site contains a wealth of information about careers in all fields. Click on "Sales,"...
-
The physical properties of D 2 O differ from those of H 2 O because (a) D has a different electron configuration than O. (b) D is radioactive. (c) D forms stronger bonds with O than H does. (d) D is...
-
In January 2022, the nominal interest rate on a 1-year Treasury bill was 0.53 percent. From January 2022 to January 2023, the consumer price index rose from 283 to 301. If you bought the 1-year...
-
On December 31, 2016, the ledger of Hernandez Company contained the following account balances: All the accounts have normal balances. Journalize the closing entries. Use 4 as the general journal...
-
1. Electric potential is given by V=6x-8xy-8y+6yz - 4z Then magnitude of electric force acting on 2C point charge placed on origin will be :- (1) 2N (2) 6N (3) 8N (3) 8N (4) 20 N 2. Figure shows...
-
Jarlsberg cheese (www.jarlsberg.com) has been well received in the US. Nearly 60 years after entering the US it is now the imported cheese with the biggest market share of its category (Swiss-like...
-
Assume that ABC is a corporate shareholder of DEF Corporation. In this case, the dividends received by ABC are taxable at the corporate tax rates. Additionally, ABC may be subject to another level of...
-
1. HR strategy is the most important functional strategy, without synergy with the business strategy, the vision and long-term objectives cannot be implemented? ( 2. Ratio analysis, is an effective...
-
What are recommendations or strategies that can mitigate or overcome the ills that Cracker Barrel suffers?
-
Discuss, compare, and explain the dividend pattern between Microsoft and IBM. What dividend policy difference do you see? What could you tell about their business difference? What is the different...
-
Bank ADC has 2 0 0 million in loans to corporate customers and has 8 0 million in deposits it owes to customers with the same maturity. The bank has also sold 3 0 million pounds forward. Calculate...
-
If you had $500 to invest, in general, would it be riskier to invest through an intermediary or a market?
-
Fast Finance is a drive-in financial consulting business, where customers park in the parking lot and employees come by on roller skates to give them financial advice. For the month of January, Fast...
-
In Exercises 516, find the focus and directrix of the parabola with the given equation. Then graph the parabola. y 2 = 4x
-
Identify and correct the errors in the following class declaration: class nifty { // data char personality[]; int talents; // methods nifty(); nifty(char * s); ostream & operator <
-
Write a statement that assigns the sum of the first and last elements of the array in Question 3 to the variable even. Data From Question 3 Declare an array of five ints and initialize it to the...
-
Modify Listing 11.15 so that it writes the successive locations of the random walker into a file. Label each position with the step number. Also have the program write the initial conditions (target...
-
Using an economic balance sheet, which of the Laws current financial assets is most concerning from an asset allocation perspective? A. Equities B. Real estate C. Fixed income Raye uses a costbenefit...
-
Using the economic balance sheet approach, the Laws economic net worth is closest to: A. $925,000. B. $1,425,000. C. $1,675,000. Raye uses a costbenefit approach to rebalancing and recommends that...
-
Raye believes the previous advisers specification for debt is incorrect given that, for purposes of asset allocation, asset classes should be: A. diversifying. B. mutually exclusive. C. relatively...
Study smarter with the SolutionInn App