I have this Code

#include <iostream.h>

int mult(int x, int y);

int main()
{
int x, y;
cout<<"Please input two numbers to be multiplied: ";
cin>>x>>y;
cout<<"The product of your two numbers is "<<mult(x, y);
return 0;
}
int mult(int x, int y)
{

return x*y;
}

it works fine but how would i be able to get it to say Pick More numbers to multiply and then do the same job as the code above ?
ICE

2. One method would be to use default paramaters in your function, for example:
Code:
`int mult(int x, int y, int z = 1)`
And now Z is a default paramater, which means by default its 1, but you can also change it. So if you were to return x*y*z with your function being called: mult(5,5) you would get 25. However, you could also use mult(5,5,5) and you would get 125.

I hope you're following this, its sort of ugly (English) wise, but it shouldn't be too hard. Your new code would look like this:

#include <iostream.h>

int mult(int x, int y, int z = 0);

int main()
{
int x, y;
cout<<"Please input two numbers to be multiplied: ";
cin>>x>>y;
cout<<"The product of your two numbers is "<<mult(x, y);
cout<<"Please input three numbers to be multiplied: ";
cin>>x>>y>>z;
cout<<"The product of these three numbers is "<<mult(x, y, z);
return 0;
}
int mult(int x, int y, int z)
{
return x*y*z;
}

3. with a control loop. There are three types initialized by the keywords for, while, and do/while. There usage should be well demonstrated in any C++ textbook you have available or in the tutorial at the home page of this board.

4. ## Dunt work

thers errors :
Im a newbie
so i dont know how to fix em
ICE

5. ## HELP ME AGAIN

#include <iostream.h>

int mult(int x, int y, int z = 0);

int main()
{
int x, y;
cout<<"Please input two numbers to be multiplied: ";
cin>>x>>y;
cout<<"The product of your two numbers is "<<mult(x, y);
cout<<"Please input three numbers to be multiplied: ";
cin>>x>>y>>z;
cout<<"The product of these three numbers is "<<mult(x, y, z);
return 0;
}
int mult(int x, int y, int z)
{
return x*y*z;
}

thats my code
whats wrong and what will be the final code ?

6. ## Wrong

Whoops
that was the wrong code
#include <iostream.h>

int mult(int x, int y);

int main()
{
int x, y;
cout<<"Please input two numbers to be multiplied: ";
cin>>x>>y;
cout<<"The product of your two numbers is "<<mult(x, y);
return 0;
}
int mult(int x, int y)
{

return x*y;
}

thasts the wright 1
the codes fine i just want it to say pick another number then repeats the code again!

7. you could do this:

char more = 'y';

after you declare x and y. Then use a while loop with the conditional being (more == 'y') and after the second cout statement put a third cout telling the user to enter a lower case y if they wish to do more multiplication problems and anything else if they wish to stop. Accept user input using cin placing the input in more. Used in this way the variable more is sometimes called a flag to indicate which option to follow. Use of control loops and flags is very common in programming and is a technique you should become comfortable with.