I keep getting the error messages like uresolved external symbol "int_cdecl rand_int(int,int)"

Prompt is to create a menu driven function where the user can choose from making a square or generating lottery numbers or exit the program
#include <iostream>
#include <cstdlib>

using namespace std;

int main()
{

// Declare the variables
int choice;

//Set up the menu selections
cout << "Make a selection \n";
cout << "1. Print a hollow square \n";
cout << "2. Lottery drawing \n";
cout << "3. Exit \n \n";
cin >> choice;

// Declare the variables for the square
int size;
int row = 1;
int column = 1;

// variables for lottery drawing
int rand_int(int min, int max);
unsigned int even = 0, first_ball, second_ball, third_ball;
int number_drawings = 0, drawing_request = 0;

// Set up the selection for the menu
switch (choice)
{
case 1:
cout << "\n \n Enter the size for square: ";
cin >> size;

// Setting the square
while (row <= size)
{
while (column <= size)
{
if (row == 1 or row == size or column == 1 or column == size)
cout << "*";

else
cout << " ";

column++;
}

cout << endl;
row++;
column = 1;
}
break;

case 2:
// Setting up the generator
void lottery();
{
// User input the number of desired drawings
cout << "How many drawing would you wish? ";
cin >> drawing_request;

// Loop for the user input a number zero or less
while (drawing_request <= 0)
{
cout << "Please input a number that is greater than zero.";

cout << "\n \n How many drawing would you wish?";
cin >> drawing_request;
}

// Loop for the random generation of the lottery numbers
while (number_drawings < drawing_request)
{
number_drawings++;

// ball one drawing
first_ball = rand_int(1, 10);

// ball two of the drawing
do

second_ball = rand_int(1, 10);

while (second_ball == first_ball);

//drawing for third ball
do
third_ball = rand_int(1, 10);

while ((second_ball = third_ball) || (first_ball = third_ball));

//Print the generated numbers
cout << "\n \n Generated lottery numbers are: " << first_ball << "-" << second_ball << "-" << third_ball << endl;

if ((first_ball % 2 == 0) && (second_ball % 2 == 0) && (third_ball % 2 == 0))
even++;
}

// the percent of the numbers will come out even
cout << "\n Percentage that the lottery numbers will contain three even numbers: " << 100.0*even / number_drawings << endl;
}
break;

case 3:
// Exit the menu
cout << "\n \n Good Bye!";
break;

}

return 0;
}
Last edited on
//drawing for third ball
do
third_ball = rand_int(1, 10);

while ((second_ball = third_ball) || (first_ball = third_ball));

It’s the first time I meet this syntax. Is it correct? May a do-while loop be written without braces when there’s just one statement inside it?
It’s the first time I meet this syntax. Is it correct?

The syntax is valid but the loop will not run correctly because he should have used == instead of = inside the loop condition.

May a do-while loop be written without braces when there’s just one statement inside it?

Yes, same as with if, else, while, for, and even switch though that is kind of useless.
Last edited on
Thanks, Peter87 - invaluable, as usual!
Topic archived. No new replies allowed.