O'Reilly logo

C# Primer Plus by Klaus Michelsen

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

Review Questions

1:What is the output from the following method if you call it with the argument 1?
01: public static void Recurs(int number)
02: {
03:     if(number > 8)
04:         return;
05:     else
06:     {
07:         Console.WriteLine("Number: { 0} ", number);
08:         Recurs(number * 2);
09:     }
10: }
2:Identify in the Recurs method of question 1 the main ingredients found in most successful recursive methods.
3:Rewrite the Recurs method in question 1 so that it (by still using recursion) provides the following output if called with the argument 16.
Number: 16
Number: 8
Number: 4
Number: 2
Number: 1
4:Which technique provides for the most efficient solution recursion or iteration? Why?
5:The following Sum method is supposed to calculate the sum of a series of numbers ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required