S
SpiralCorp
int divide (int a, int b)
{
int r;
r=a/b;
return (r);
}
int main ()
{
int result = divide (20,4);
cout << result
return 0;
}
--------------
I understand the use of the return statement as exemplified in the
example above. However, I was wondering what was the proper way for a
function to return more than one value and subsequently store those
values in their own independent variables. For instance, if the above
function were to return two different results, how would I assign them
each to their own variable by means of the return statement?
I figured I could achieve this by declaring the variables in the main
function and then passing them by reference to the function so they
could be changed within (This would work without the use of the return
function ofcourse), but something tells me this method is not exactly
kosher?
What do you guys think, whats the proper way of doing it?
{
int r;
r=a/b;
return (r);
}
int main ()
{
int result = divide (20,4);
cout << result
return 0;
}
--------------
I understand the use of the return statement as exemplified in the
example above. However, I was wondering what was the proper way for a
function to return more than one value and subsequently store those
values in their own independent variables. For instance, if the above
function were to return two different results, how would I assign them
each to their own variable by means of the return statement?
I figured I could achieve this by declaring the variables in the main
function and then passing them by reference to the function so they
could be changed within (This would work without the use of the return
function ofcourse), but something tells me this method is not exactly
kosher?
What do you guys think, whats the proper way of doing it?