Hello, I am a new CS student and I am taking a C++ course. I am running into problems with a simple number generation program. Basically, I have to generate 2 single digit numbers and then request the user to multiply them. (I know there is nothing in there yet for the user input or multiplication) I am having a problem with the functions. When I call randomGen
in the below example, I get an error saying that the variables are uninitialized. If I put int
in front of num1, num2
in the call, I get more errors. Anyone know what I am doing wrong? I have been working on this one section for a while, reading tutorials and what not, to no avail.
int randomGen (int num1, int num2);
int multiply (int num1, int num2);
void main ()
{
int num1, num2;
cout << "Multiplication\n";
randomGen (num1, num2);
cout << "What is " << num1 << " times " << num2 << endl;
}
int randomGen (int num1, int num2)
{
num1 = rand () % 10;
num2 = rand () % 10;
return num1, num2;