#include<iostream>
int fun(int &x,int y=10)
{
if(x%y==0)
return (++x);
else
return (y--);
}
int main()
{
int p=10,q=13;
q=fun(p,q);
cout<<p<<q<<endl;
q=fun(q);
cout<<p<<q<<endl;
q=fun(p);
cout<<p<<q<<endl;
return 0;
}
The output as shown is as follows:
1013
1010
1111
But when I try to solve it using pen and paper I am stuck. Please show me how to arrive at the correct output so as to keep my concepts clear.