/*This code is used to get a random number
between 1 and 50. User inputs how many
numbers they want, between 1 and 10. */
#include <iostream.h> //Needed for input/output
#include <time.h> //Need this so random will work
#include <stdlib.h> //Need this for random functions
void main()
{
srand(time(0)); //Gets internal clock time for random
int Rand_Num; //Variable for random number
int Input; //Variable for Input
Rechoose: //Rechoose subroutine
cout << "Enter a number 1 - 10: "; //Prompt user
cin >> Input; //Get input from user
if(Input >= 1 && Input <= 10) //Checks if greater than 1 and less than 10
{
for(int i = 0; i < Input; i++) //Outputs a random number up until number of user input
{
Rand_Num = (rand() % 50) + 1; //Makes Rand_Num a random number, the + 1 makes it so it is 1+ and not 0+
cout << Rand_Num << '\n'; //Outputs random number
}
}
else
{
goto Rechoose; //If input isnt between 1 and 10 then makes user rechoose
}
}