#include <iostream> // Input/Output library
#include <cmath> // Math library for C/C++
#include <string> // String library (used for user inputs)
using namespace std; // Namespace for easier outputs
int main() { // Main
/*
// Gets the user input
string value;
cout << "Enter a numeric value (INT): " << endl; // Prints a response to ask for a user input
cin >> value; // Reads the user input
*/
// Convets user input to an int value
int val = rand() % 15 + 1;
/*
try {
val = stoi(value);
} catch(const invalid_argument& e) {
cerr << "Invalid" << endl;
return 1;
} // End of conversion
*/
for (int i = 0; i < val; i++) {
if (i == 4) {
cout << "Skipped 4!\n";
continue; // Skips number (in this case this will skip 4)
} else if (i == 7) {
cout << "Stopped at 7!";
break; // Stops the program when i gets to 7
}
cout << i << "\n"; // Prints the numbers
}
return 0; // ALways return 0
}
To embed this project on your website, copy the following code and paste it into your website's HTML: