List of all available Websheets
Viewing cpp/var-expr/coins 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 | <p>Write a program that generates 2 random flips of a fair coins (0 = heads, 1 = tails).</p> <p>Use the <code>rand()</code> function to generate a random integer between 0 and about 2 billion. Then convert that to a 0 or 1 with equal probability.</p> |
Public permissions | |
Remarks Comments, history, license, etc. | Copied from problem cpp/var-expr/change (author: redekopp@usc.edu) Copied from problem cpp/cin/deg2rad (author: redekopp@usc.edu) Copied from problem cpp/var-expr/in_n_days (author: redekopp@usc.edu) Copied from problem cpp/var-expr/char_arith (author: redekopp@usc.edu) Copied from problem cpp/var-expr/hello (author: daveagp@gmail.com) |
Engine | |
Template / Reference solution |
using namespace std; int main() { int flip1, flip2; \hide[ // This "seeds" the random number generator to allow // different random values to be produced on each program run srand(time(0)); ]\ \[ flip1 = rand() % 2; flip2 = rand() % 2; ]\ cout << "Flips are " << flip1 << " and " << flip2 << 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 [{}] | [ {"stdin":"", "args":[]} ] |
Solution visibility | |
Is example? i.e., just a demo |
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'.