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

List of all available Websheets


Viewing cpp/control/loop_example1 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
 
Convert the following tasks of printing out the first 5 integers (starting from 0) and summing up the first 10 <strong>even</strong> integers to use loops
Remarks
Comments, history, license, etc.
 
Copied from problem cpp/control/count_example (author: redekopp@usc.edu)
remove
Engine
Template / Reference solution
 
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
   int sum = 0;
\[
REDACTED
\show:
   cout << 0 << endl;   
   cout << 1 << endl;   
   cout << 2 << endl;   
   cout << 3 << endl;   
   cout << 4 << endl;   
   sum = sum + 0;   
   sum = sum + 2;   
   sum = sum + 4;   
   sum = sum + 6;   
   sum = sum + 8;   
   sum = sum + 10;   
   sum = sum + 12;   
   sum = sum + 14;   
   sum = sum + 16;   
   sum = sum + 18;   
   
]\
   cout << "Sum is " << sum << endl;
      
   return 0;
}
C++ test suite
json list of stdin/args tests
e.g. [{"stdin":"hi", "args":["4", "5"]},
{"stdin":"noargs"}]

to just run once with no input use [{}]
 
[{}]
Solution visibility remove
Is example?
i.e., just a demo
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'.