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.
Property | Value |
---|---|
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 | |
Engine | |
Template / Reference solution |
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"] |
Solution visibility |
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'.