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

List of all available Websheets


Viewing cpp/cs103/hw-arrays/reverse4 by daveagp@gmail.com. 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 4 numbers as input, and prints them out in reverse 
order. For example, if the input is
<pre>
4 42 15 13
</pre>
then the output should be
<pre>
In reverse order, the numbers were: 13 15 42 4
</pre>
Using a loop is not required.
Engine
Template / Reference solution
 
#include <iostream>
using namespace std;
int main() {
   int nums[4]; // declare array of ints called "nums"
   cin >> nums[0] >> nums[1] >> nums[2] >> nums[3];
   cout << "In reverse order, the numbers were: ";
\[
REDACTED
]\
   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": "4 42 15 13"},
   {"stdin": "23 34 1 7"},
   {"stdin": "5 5 5 -5"}
]


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'.