#include <iostream>
usingnamespace std;
void multiplicationFunction(); //multiplying input and num in the main function
{
cout << num << " times " << input << " equals " << num * input << endl;
}
void additionFunction(); //adding input and num in the main function
{
cout << num << " added to " << input << " equals " << num + input << endl;
}
int main() //using the while loop to run through both void functions 4 times for the integers 1-4
{
int input = 0, num = 0;
cout << "Please enter an integer: " << endl;
cin >> input;
while(int num = 1; num <= 4; num++)
{
multiplicationFunction();
additionFunction();
}
return 0;
}
#include <iostream>
usingnamespace std;
void multiplicationFunction(int num, int input) //multiplying input and num in the main function
{
cout << num << " times " << input << " equals " << num * input << endl;
}
void additionFunction(int num, int input) //adding input and num in the main function
{
cout << num << " added to " << input << " equals " << num + input << endl;
}
int main() //using the while loop to run through both void functions 4 times for the integers 1-4
{
int input = 0, num = 0;
cout << "Please enter an integer: " << endl;
cin >> input;
while (num < 4) {
multiplicationFunction(input, num);
additionFunction(input, num);
num++;
}
return 0;
}
Your addition/multiplication functions don't know what "num" and "input" are b/c they are scoped to inside main(). You need to pass them as parameters. like this:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19
void multiplicationFunction(int input, int num);
{
cout << num << " times " << input << " equals " << num * input << endl;
}
//TO DO: See if you can figure out the addition function ;)
int main() //using the while loop to run through both void functions 4 times for the integers 1-4
{
int input = 0, num;
cout << "Please enter an integer: " << endl;
cin >> input;
while(int num = 1; num <= 4; num++)
{
multiplicationFunction(input, num);
additionFunction();
}
return 0;
}