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

List of all available Websheets


Viewing cpp/control/count_example 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
 
Shows how a loop will sequentially (one after the next) repeat a body of statements while a condition is true.
This program should print 0 through 4 due to the while loop and 20-24 due to the for loop.
Engine
Template / Reference solution
 
#include <iostream>
using namespace std;
int main(int argc, char* argv[])
{
   
   cout << "While loop prints: " << endl;
   int i = 0;
   while(i < 5){
      cout << i << endl;
      i++;
   } 
   
   cout << "For loop prints: " << endl;
   for(int j=0; j < 5; j++){
      cout << j << 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'.