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

List of all available Websheets


Viewing cpp/var-expr/math 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 program that takes integer inputs
<code>x</code> and <code>y</code>, and outputs 3 lines containing:
<ul>
<li>Their difference
<li>Their average
<li>The quotient (as a double) of <tt>x</tt> divided by <tt>y</tt> 
</ul>
For example, if the input is <tt>18 4</tt>, the output should be
<pre>
14
11.0
4.5
</pre>
Public permissions remove
Remarks
Comments, history, license, etc.
 
Originally by Mark Redekopp (redekopp@usc.edu) and Dave Pritchard (daveagp@gmail.com)
remove
Engine
Template / Reference solution
 
#include <iostream>
#include <cstdlib>
using namespace std;
int main() {
\[
   int x, y;
   cin >> x >> y;
   cout << x-y << endl;
   cout << (x+y)/2.0 << endl;
   cout << static_cast<double>(x) / y << 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": "20 3"},
   {"stdin": "5 4"},
   {"stdin": "100 4"},
   {"stdin": "3 20"}
]
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'.