answersLogoWhite

0


Best Answer

Write a program using recursion which should take two values and display 1st value raised to the power of second value.

User Avatar

Wiki User

13y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: Write a program using recursion which should take two values and display 1st value raised to the power of second value?
Write your answer...
Submit
Still have questions?
magnify glass
imp
Continue Learning about Engineering

What are the advantages of the recursion in c plus plus?

Any problem that can be solved by dividing the problem into smaller problems of the same type is a good candidate for recursion. However, there are actually very few applications that cannot be resolved more efficiently with an iterative loop. It therefore pays to know when recursion is unavoidable and when it is optional. The main benefit to recursion is that each instance of the function maintains its own set of non-static local variables completely independently of all other instances. But if these variables are of no use to the function when a recursive call returns, then an iterative implementation would be more efficient. Function calls are expensive in terms of memory consumption and performance, so the fewer we make, the better. A classic example of recursive application is the quicksort algorithm. In simple terms, quicksort is a function that accepts a subset of data. The data is usually stored in an array and the function accepts the left and right index of the subset to be sorted. Initially this will be lower and upper bounds of the entire array, but if the indices indicate a subset with fewer than 2 items, the function immediately exits. This effectively defines the return path from the recursions. Assuming there are 2 or more items, the function selects one of the items (the pivot) and then sorts the array such that items less than the pivot are placed to its left, and items greater or equal to its right. This moves the pivot into its final position, but the items on either side may still be unsorted. Thus the function calls itself twice, once for each of these subsets, which gradually reduces the problem down into smaller and smaller subsets until a subset has fewer than 2 items, at which point the recursion unwinds to the previous instance. Recursion is required because when the first recursive call returns, the subset to the left of the pivot is guaranteed to be sorted, but the subset to the right is not. This means we must maintain local variables in order to determine the lower and upper bounds of that subset. Although quicksort is an elegant application of recursion, there is still room for improvement. Firstly, it is better to make a recursive call upon the smaller of the two subsets. The smaller the subset, the fewer recursions that will be incurred sorting it. Secondly, since the second recursion is also the last statement in the function, there is no need to maintain the local variables when it returns. Thus the second recursion can be implemented as a tail call. This effectively means we modify the existing local variables to suit and then recall the same instance (with a goto). This reduces the depth of recursion by one function call per recursion which will quickly add up to a significant boost in efficiency.


What is the flow chart for a program that finds two product numbers?

Since all decent programming languages have the multiplication operator, you simply multiply them. If you want to go into a bit more detail, it would be a bit like this: Ask user for number "a" Ask user for number "b" Calculate result = a * b Show result (End) Use the appropriate flow chart symbols for input, etc.


The program that deng x embraced and referred to as the second revelotion included the goals of the?

Four Modernizations


Write a HTML program to insert a selection list in a form?

<select id="selectlist"><option> First</option> <option> Second</option>. This is a sample program to insert a selection list.


You have an idea for an educational computer program but you are not a program designer can you patent your idea for the game or do you have to first make the program before seeking a patent?

The U.S. has a 'working provision' patent law that requires you to exploit a patent or forfeit the patent. Second, patents are really expensive.

Related questions

What is a number raised to the second power?

A number raised to the second power is a number times itself. This can also be stated as a number squared.


What is the equal to 6 raised to the second power?

6 raised to the second power is equal to 36.


What is 18 raised to the power of 3?

What os 18 raised to the second power


What was the name of the second manned space program?

The first program to put a man in space was the Soviet Union's Vostok program, so the second manned space program would be the US Mercury program. The second US manned program was Gemini.


What is -3 raised to the second power?

9


6 raised to second power?

36


What happens when a square root radical is raised to the second power?

they cancel each other out. the square root of 5 raised to the second power = 5


When you multiply a number by itself you raise the number to the second-?

It is raised to the second power


What is the greatest common factor of 110x raised to the 2nd power 30x raised to the 7th power and 60x raised to the 8th power?

It is 10x raised to the second power.


What apartments have a second chance program in marietta ga?

What apartment in Mariette have a second chance program


What does 7 raised to the second power mean?

7 raised to the second power is the same way as saying "seven squared". Seven squared is equal to 49.


How do you connect multiple monitor to a windows 7 PC?

First, check out your graphics adaptor card to ensure that it has a multiple monitor capability. Generally, you might expect to find 2 HDMI connector or 2 Display Port connectors, or two . . . well, you get the idea. If the adaptor is NOT capable of running multiple displays, stop here and go buy one that does, and replace your current card with the new one. It would be good if the new card has a connector that is the same as the one on your second display ! If not, you can buy an adaptor for the graphics card end of your cable. Display Port to HDMI is pretty expensive . . . With computer off and display off, connect the cord (cable) to the computer graphics card and the other end to the second display.' Turn on the power on the display and let it get done powering up. Then power up the computer. At some point, the computer will detect the second monitor and show you a screen where you can choose which display will be your main display and of course the other one will be your secondary display. Their images onscreen will be labeled with a huge "1" and "2". Move about halfway down the page and select how the two displays will work with each other. From the little pulldown box, select "Extended", or something very close to that. Hit "apply", then try to move your cursor over to the new second display and back. If it works, you're in business. You can drag any desktop icon or open program over to the other display (and back). I like to have my email program and and the command history pane from my AutoCAD program on the second display so they are always visible. If you can't move your cursor from one display to the other, then you will need help, either in the form of a How-To article or from a computer sales or repair place. There is not enough room here to explain how to proceed. Good Luck!!!