See the bottom for how to submit your work.
Checking if a given input is a letter or notDebug your code until it runs correctly. Circle below how you wrote your code.
Good input if the user enters a positive integer that divides
1155 evenly, and Bad input for anything else.
#include <iostream>
using namespace std;
int main()
{
int k;
cout << "Enter positive integer that divides 1155: ";
cin >> k;
if (1155 % k == 0 && k > 0)
cout << "Good input" << endl;
else
cout << "Bad input" << endl;
return 0;
}
Input:
Note: each expression should be taken
as independent. I.e. if one expression modifies some variable values, those
modifications do not carry over to the next expression.
|
|
|
|
hw.cpp that works like this
(with the user input colored in red):
| That is, the program receives two numbers for a and b (separated by a comma), receives a command, and then executes it. |
The following commands are possible:
add num to a
add num to b
square a
square b
~/bin/submit -c=IC210 -p=hw06 hw.cpp