Not logged in. Log in with GitHub. About Websheets.

List of all available Websheets


Viewing cpp/recursion/countup by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
PropertyValue
Description
html markup
shown to student
 
Write a recursive function <tt>countup(int n)</tt> that prints out
<tt>Blastoff!</tt>, followed by the numbers from 1 to n. For example
<tt>countup(5)</tt> should print out
<pre>
Blastoff!
1
2
3
4
5
</pre>
Public permissions remove
Engine
Template / Reference solution
 
#include <iostream>
using namespace std;
void countup(int n) {
\[
  // base case
  if (n == 0) {
     cout << "Blastoff!" << endl;
  }
  // recursive case
  else {
     // recursive call
     countup(n-1);
     cout << n << endl;
  }
]\
}
C++ test suite
See manual
 
[
   ["check-function", "countup", "void", ["int"]],
   ["call-function", "countup", ["5"]],
   ["call-function", "countup", ["10"]],
   ["call-function", "countup", ["1"]]
]
Forbidden substrings
json list of strings
e.g. ["for","while"]
 
["#include", "for", "while"]
remove
Solution visibility remove


Optional properties:

Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.