//declaring the constant number and naming it as LUCKY
const int LUCKY = 6;
//declaring the functions for introduction, findhowmanyequal and didtheproducthit
void introduction ();
int findhowmanyequal (int a, int b, int c);
void didtheproducthit (int, int);
int main ()
{
int num1, num2, num3;
int calculate=0;
char answer;
//call for "introduction" function
introduction();
do {
cout << "\nPlease type in any three numbers: " << endl;
cin >> num1; cin >> num2; cin >> num3;
cout << "The three original numbers are: " << num1 << "\t" << num2 << "\t" << num3 << endl;
calculate ++;
// call for "findhowmanyequal" function
findhowmanyequal(num1, num2, num3);
// call for "didtheproducthit" function, while giving it three possible product variables
didtheproducthit(num1, num2);
didtheproducthit(num1, num3);
didtheproducthit(num2, num3);
cout << "\nIf you want to continue please press Y, if not press N" << endl;
cin >> answer;
}
while (answer == 'y'); // if user will press the 'y' key for yes then operation will restart from the main; if any other key then it will stop
cout << "The number of sets entered is: " << calculate << endl;
return 0;
}
void introduction () // this function will be showed only once in the header of the input window
{
cout << "Welcome to assignment number 3! \nThis assignment was written by Anton Kramarenko. \nThe lucky number is: " << LUCKY << endl;
}
int findhowmanyequal (int a, int b, int c) // this function checks if entered numbers are equal to the constant "LUCKY" number
{
int sum=0; // to calculate the total times entered data is equal to "LUCKY"
if (a==LUCKY)
sum++;
if (b==LUCKY)
sum++;
if (c==LUCKY)
sum++;
cout << sum << " of the numbers entered is equal to the lucky number " << LUCKY <<endl; // display the total times the input is equal to "LUCKY" number
return sum;
}
void didtheproducthit (int d, int e) // to check if the product of the entered numbers is equal to the "LUCKY" number
{
if (d*e==LUCKY)
cout << d << " multiplied by " << e << " is equal to the " << LUCKY << endl;
else
cout << d << " multiplied by " << e << " is not equal to " << LUCKY << endl;
if ( (a==LUCKY) || (b==LUCKY) || (c==LUCKY) )
sum++;
By the way, when posting code, please use the code tags. They appear as "<>" in the Format box. It makes it easier for others to read and comment on your code.