Alright, so in your main function just prompt the user for one number then. To do that, just get rid of number2 and the lines that use it. Your multiplyNumbers (magnitude) function should take an integer argument (n) and return n*10.
#include <iostream>
usingnamespace std;
int main()
int multiplyValue (int &number1*10) {
{
cout << "Enter your first number";
cin >> number1;
cout << "Your entered numbers is " << number1 << endl;
}
{
int main()
int number1, number2;
cout << "This will multiply the number by 10 and show an answer."<<endl;
cout << "Enter your number: ";
cin >> number1;
cout << "\nYou entered " << number1 << endl;
int result = multiplyValues(number1*10);
cout << "The answer by multiplying " << number1*10 << " is " << result << endl; }
the compiler does not like line 5 it says error expected intilizer before int.
#include <iostream>
usingnamespace std;
int magnitude (int &number1) {
{
cout << "Enter your first number";
cin >> number1;
cout << "Your entered numbers is " << number1 << endl;
}
{
int main()
int magnitude (int n)
{
return n*10;
}
int number1;
cout << "This will multiply the number by 10 and show an answer."<<endl;
cout << "Enter your number: ";
cin >> number1;
cout << "\nYou entered " << number1 << endl;
int result = magnitude(number1);
cout << "The answer by multiplying " << number1 << " is " << result << endl; }
is that the final result? it still finds things wrong.
You have multiple syntax errors. The function magnitude should appear once, in its entirety, before the start of the main function. Also, get rid of the input code in the magnitude function, it's really out of place.
#include <iostream>
usingnamespace std;
int magnitude(int n)
{
cout << "Enter your first number";
int number1;
cin >> number1;
cout << "Your entered numbers is " << number1 << endl;
}
int main()
{
int number1;
cout << "This will multiply the number by 10 and show an answer."<<endl;
cout << "Enter your number: ";
cin >> number1;
cout << "\nYou entered " << number1 << endl;
int result = magnitude(number1);
return number1*10;
cout << "The answer by multiplying " << number1 << " is " << result << endl; }
The magnitude function you're using is wrong. Use the one I gave you. In main, prompt the user for one number, then call magnitude and output the return value of magnitude in main.
#include <iostream>
usingnamespace std;
int magnitude (int n)
{
return n*10;
cout << "Enter a number";
int number1;
cin >> number1;
cout << "Your entered numbers is " << number1 << endl;
}
int main()
{
int number1;
cout << "This will multiply the number by 10 and show an answer."<<endl;
cout << "Enter your number: ";
cin >> number1;
cout << "\nYou entered " << number1 << endl;
int result = magnitude(number1);
return number1*10;
cout << "The answer by multiplying " << number1 << " is " << result << endl; }
setting it that way blocks out the program to keep asking for numbers
#include <iostream>
usingnamespace std;
int magnitude (int n)
{
return n*10;
}
int main()
{
int number1;
cout << "This will multiply the number by 10 and show an answer."<<endl;
cout << "Enter your number: ";
cin >> number1;
cout << "\nYou entered " << number1 << endl;
int result = magnitude(number1);
return number1*10;
cout << "The answer by multiplying " << number1 << " is " << result << endl; }
#include <iostream>
usingnamespace std;
int magnitude (int n)
{
return n*10;
}
int main()
{
int n;
cout << "This will multiply the number by 10 and show an answer."<<endl;
cout << "Enter your number: ";
cin >> n;
cout << "\nYou entered " << n << endl;
int magnitude(n);
return n*10;
cout << "The answer by multiplying " << n << " is " << magnitude << endl; }