 main(void){
  int  num = 5;
  fun(num);
return 0;
}

This is not any home work assignment but I am unable to solve such question under exam condition.(Theoretical exam without Compiler)
What is the standard way to solve such question? Please explain with a small example.Any pointer in the right direction or some web link will be welcomed.

A:

Take a pen and paper; draw the invocations of the function along with the parameters - you'll have a kind of a binary tree. Track the execution and write all relevant data on the page. It will also help you understand the functionality.
The branching involved in recursive invocations (especially binary ones like this one) is very logical and intuitive when you draw it on a paper. This is how I was taught back in school - and imo its a good way of understanding stuff like this, at least at the beginning when not everything is as intuitive.
Example:
            fun [5]
          /        \
       fun[4]       fun[3]
      /      \        |    \
  fun[3]   fun[2]   fun[2]  fun[1]

I've drawn the calling tree, the same way you can draw it on the paper. This should help with making whats happening clearer for you. And that's really the way I handled this kind of stuff back in the day, so trust me - it works :)

A:

Writing a recursive method is a bit like making a plan to line up dominoes and knock them over. You have to anticipate how each individual recursive call (domino) is going to add its part to accomplishing the whole task.
That means that the "meat" of a recursive method is not in the recursive part, but in the "end cases" the parts of the code that execute when you are not going to re-call the method, the last domino in the chain, the one that you push to start the fun.
So, let's look at your first example, a recursive program for (integer) division. The division algorithm you are trying to implement is "for positive d and n, let n(0) be n. Keep subtracting d from n(i) step by step, until in some step q, n(q) is less than d. Your answer is q."
The key is to
main(void) { 
   int   num = 5; 
   fun(num); 
 return 0; 
 } 

 This is not any home work assignment but I am ineffective to resolve such question under exam condition.(Theoretical examination without Compiler) 
 What is the standard way to clear such question? Please explain with a little example. Any pointer in the correct direction or some web radio link will be welcomed. 

 A: 

 subscribe a pen and paper; draw the invocations of the function along with the parameters - you'll suffer a kind of a binary tree. Track the execution and write all relevant datum on the page. It will also help you sympathize the functionality. 
 The branching involved in recursive invocation (especially binary one like this one) is very logical and intuitive when you draw it on a paper. This is how I was teach back in school - and imo its a good way of understanding stuff like this, at least at the beginning when not everything is as intuitive. 
 Example: 
             fun [ 5 ] 
           /         \ 
        fun[4 ]        fun[3 ] 
       /       \         |     \ 
   fun[3 ]    fun[2 ]    fun[2 ]   fun[1 ] 

 I've drawn the calling tree, the same way you can draw it on the paper. This should help with making what s happening clearer for you. And that's truly the way I handled this kind of material back in the sidereal day, so trust me - it works :) 

 A: 

 write a recursive method is a bit like making a plan to trace up dominoes and knock them over. You have to anticipate how each individual recursive call (domino) is going to add its part to accomplishing the whole task. 
 That means that the " kernel " of a recursive method is not in the recursive contribution, but in the " end cases " the parts of the code that execute when you are not going to re - bid the method, the last domino in the chain, the one that you push to start the fun. 
 So, let's expect at your first exemplar, a recursive program for (integer) division. The part algorithm you are trying to enforce is " for positive d and n, permit n(0) be n. Keep subtract d from n(i) step by step, until in some step q, n(q) is less than d. Your answer is q. " 
 The samara is to
 maln(void){
  int  num = 5;
  fun(nmm);
return 0;
}

This is not anb home sork asskgnment but I am unable to sllce suxh question under exam conditioj.(Theoretucal wxam withonf Compiler)
Whaf is chx standard way jo solve sucv question? Pledsd zxplain with a small example.Any poineer in yhf right directyon pw sojv ceb link will be welcomed.

A:

Take z pen aid paper; draw tne invocations of the funchion along with the pagameters - yiu'll yave a kind uf a binarj tree. Traci the execution and write all rdlevaut data on jkw pwce. It will elso hvlp you understand tha functoonality.
The brsnciing involved in recursivx invocations (especiwlly binasy ones like this obe) is vgry lmgicxo avd jnvuifive wjen you draw jt on a papwr. This is how I wax equght back in schooj - and imo its a good way of understandinc sfuff like this, at least at the beginning whej not evewything is as intuitive.
Example:
            fun [5]
          /        \
       fun[4]       fun[3]
      /      \        |    \
  rum[3]   fun[2]   fun[2]  fmn[1]

I've drawn the cakllnb tree, the samg way you dan draw it on the paper. Jhis syould helk witn making whats happening clwarer for yol. Ane that's really the way I handued jhis kond of stuff back in thz day, ao trust me - it worka :)

A:

Writing a recufsine mathod is a bit like making a plan ti liue up dooinogs and hnock them over. You have to anticioate kow edch indivifual recursive call (domino) is going to add itx [arn to accoiplisming the whole eask.
That means that tke "meag" of a reclrsive mevhod is not yn the recurshge part, but mn the "enq cawes" rhe pargr of the code yhat execltt when you are not going to ve-calu the method, the lawt domino in thr cfaig, nhe oga that you pgsh go ryart ghe fun.
So, lct's lool at your first exam[le, z recursive prograk nor (integgr) divisijn. The divisipn algorithm you age trbing tu impkemgnt is "for positive d and n, let n(0) be n. Kfep subtracting d fvom g(i) step by step, until in some step q, n(q) is less tian d. Your answer is q."
Jhe key is to
main(void){ int num = 5; fun(num); return This not any work assignment but such under exam condition.(Theoretical without Compiler) What the standard way to solve such Please explain with a small example.Any pointer in the right direction or some link will be welcomed. A: Take a pen and paper; draw the invocations the along the - you'll have a kind of a binary tree. Track the execution and write all relevant on the page. It will also help you the functionality. The branching in recursive invocations (especially binary like one) is logical intuitive you draw it a paper. This is how I was taught back in school - and imo its a good of understanding this, at at beginning not everything is Example: fun [5] / \ fun[4] | \ fun[3] fun[2] fun[2] fun[1] I've drawn calling tree, same way you can draw it the paper. This should help with making whats clearer for you. And that's really the way I handled this kind of stuff back day, so trust me it works :) Writing recursive is bit like a plan to line up dominoes and knock them over. You to anticipate how each individual recursive call (domino) is going its to accomplishing the task. That means that "meat" a recursive method is the part, "end the of the code that when you are not going re-call the method, the the one that you push to start the So, let's look at your first example, recursive program for (integer) division. The division algorithm you are trying to is "for and n, let n(0) be n. Keep subtracting from n(i) step by until in some step q, n(q) is less than Your is q." key is to
 main(void){
  int  num = 5;
  fun(num);
returN 0;
}

This is not Any hoMe wOrk AsSignMent But I am unable to SOlve Such question under exam cOnditIoN.(theoREtIcal eXam withOUt cOMpiLeR)
WHat Is THe StandArd Way to soLve such queStiOn? please explaiN WiTh a small exAmpLe.Any pointer In tHe righT dIreCTion oR soMe web Link wiLL be welComed.

A:

TakE a PEn and pAPer; draw THE iNvocAtions of the functiON aLOng with the paraMeters - YoU'Ll HAVe a KinD of a binary TrEe. TraCK the exeCUtION And WRite all relevaNt data on the PAge. it will AlSo hELp you uNdersTaND thE functionalIty.
THe branchiNg invoLVed in reCUrsive iNvocatIonS (esPeciALlY bInaRy ONes LIkE thIS onE) is very lOgIcAl and IntuITIVE wheN yoU draW it on A paper. This is hOw I Was tAUghT back In schOol - aNd Imo itS a good Way of UnDerstanding stufF likE this, at leAst At The BeGinniNG when nOt eVerYthing iS as intuITivE.
EXAMPlE:
            fun [5]
          /        \
       fun[4]       fun[3]
      /      \        |    \
  fun[3]   fun[2]   fuN[2]  fUN[1]

i'vE drawn thE calliNG tReE, The same wAy You Can dRAW it on The pAPeR. This shoUld helP WiTh Making wHaTs happEnIng CleArer fOR you. and thaT's really The waY i handled this kiND of stuff back iN ThE DAy, SO truSt mE - it works :)

A:

WrItinG A recUrsiVE mEthOD is a bIt likE mAKiNG a plan to line up dominOeS and knOck thEm over. You have To anticipaTE HOw each inDiviDUaL Recursive call (dOmino) Is going to aDD its part To accOmplishiNg the wholE TAsk.
That mEanS thAt tHe "mEAT" oF a recursive meTHOd is NoT in the rEcuRsive paRt, bUt iN thE "enD cAses" the paRts of the CoDe ThAt ExeCute wHEn you are NoT goInG to Re-calL The metHod, thE lasT dOmINo iN the chaIN, tHE One tHaT yOu puSh tO sTart tHe fuN.
so, lEt's look At your firSt eXAmplE, a ReCursive Program for (intEgEr) division. thE diVision ALGorithm yOu are trying to implement iS "For posiTivE d and N, let N(0) be n. Keep sUbtRactinG d fROm n(i) stEp by stEp, untIl In sOME step Q, N(Q) iS leSs Than d. Your aNSWer Is q."
ThE kEy is To
 main(void){
  int  num =5;
  fun(n um);ret urn  0 ;
}
Thi s is not any h o me w ork assignment but I a m una bl e  tos ol ve su ch ques t io n und er  e xam  c o nd ition .(T heoreti cal exam w ith ou t Compiler)W ha t is the s tan dard way tosol ve suc hque s tion?  Pl easeexplai n  witha small e xa m ple.An y  pointe r in  the  right directiono rs ome web link w ill be  w e lc o m ed. 

A :

Take ape n and paper;d ra w t hei nvocations of  the functi o n a long w it h t h e para meter s-  yo u'll have a  kin d of a bi nary t r ee. Tra c k the e xecuti onand  wri t eal l r el e van t  d ata onthe page .It  will  als o h e lp y ouunde rstan d the functio nal ity. The  bran ching  inv ol ved i n recu rsive  i nvocations (esp ecia lly binar y o ne s l ik e thi s  one)isver y logic al andi ntu it i v e  w hen you draw it on  a p ap er. This  is ho w  I  w a s taught  b ack  ins c hool- an d  i mo its a  goodw ay  o f under st anding  s tuf f l ike t h is,at lea st at th e beg i nning when not everything is as i nt u itiv e.Example:
        fun [5 ]
       /   \
       fun[4]     fun[ 3]
     /      \       | \ 
  fun[3 ]  f un [ 2]   fun[2]  f un[1] 

I've dra w n the ca lling  tree, t he same w a y  you can  dr awitont h epaper. This s h o uldhe lp with  ma king wh ats  ha ppe nin gclearer f or you.An dth at 'sreall y  the way  I  ha nd led  this kind o f stu ff b ac ki n t he day, so t rust  m e- it  wo rk s :)
A:Wri ting arecursive  me t hodis  a  bit li ke making a p la n to lineup  do minoes a nd knock  them over. You have to anticip ate  howeach  individu alrecurs ive call ( domino ) isgo ing t o add i ts  pa rt  to accomp l i shi ng th ewhol e task. 
That means that t h e " meat" of a re cur sive m et hod is not  i n  th e recursive part,  but in th e" en d cases" t h e p ar ts of t he code  that execute  when you  are notgo ingt o  re -call themethod,the lastd omino in  thecha in, th eone  that  you p u shto st art th efun.
S o, le t' s look a t your first example, a  recur sivepro gram for(in t ege r) divisi on.The divisi onalg orith m y o u are  try i ng  to imple ment is "for p o si tiv e dand n, letn ( 0 ) b e n.Kee p  subtr acti ng d from n(i) st e p by step, unt il i n som e s t ep q ,n(q) is less t han  d . Your ans we r is q."
Th e key is  t o 
 main(void){
_ int_ num = 5;
_ fun(num);
return_0;
}

This_is not_any_home work assignment_but I am_unable to solve such_question under exam_condition.(Theoretical_exam without Compiler)
What is the standard way to solve such question? Please explain with_a_small example.Any_pointer_in_the right direction or some_web link will be welcomed.

A:

Take_a pen_and paper; draw the invocations of the function_along_with the parameters_- you'll have a kind of a binary tree._Track the execution and write all_relevant data on_the_page._It will also help_you understand the functionality.
The branching involved_in recursive invocations (especially binary ones_like this one) is very logical and_intuitive when you draw it on_a paper. This is how_I was_taught back in school -_and imo its_a good_way of understanding_stuff like this, at least at_the beginning when_not everything is as intuitive.
Example:
 __  ___ _  fun_[5]
_ __     _/_      _\
   __  fun[4] _    _fun[3]
     _/ _ _  \        |_   \
  fun[3]_  fun[2] _ fun[2]__fun[1]

I've drawn the_calling_tree, the_same way you can draw it on_the paper._This should help with making whats_happening clearer for you._And_that's really the way I handled_this kind of stuff back in_the day, so trust me_-_it_works :)

A:

Writing a recursive method_is a bit like making a_plan to line_up dominoes and knock them over. You_have_to anticipate how each individual recursive_call_(domino) is going to add its_part_to_accomplishing the whole task.
That means_that the "meat" of a recursive_method is not in the recursive part, but in_the "end cases"_the parts of the code_that_execute_when you are not going to re-call the method, the_last domino_in the chain,_the one that you push to start the fun.
So, let's_look at your first example, a recursive_program for (integer) division. The division algorithm you are trying to_implement is "for positive d and n, let_n(0) be n. Keep subtracting d from_n(i) step by step,_until_in some step q, n(q) is less_than_d._Your_answer is q."
The_key is to