(iv) The following function task(Q) is a part of some class. Assume ‘m’ and ‘n’ are positive integers, greater than 0. Answer the questions given below along with dry run / working.

int task(int m, int n)
{ if(m==n)
retum m;
else if(m>n)
return task(m-n, n);
else
retum task(m, n-m);
}

(a) What will the function task() return when the value of m=30 and n=45?
(b) What function does task() perform, apart from recursion?


Solution





Contact Us

REACH US

SERVICES

  • CODING
  • ON-LINE PREPARATION
  • JAVA & PYTHON

ADDRESS

B-54, Krishna Bhawan, Parag Narain Road, Near Butler Palace Colony Lucknow
Contact:+ 919839520987
Email:info@alexsir.com