Show the exact screen-output of each of the following programs:
c)
Hint: Assume entered value of n = 6Code:#include <stdio.h> int f (int a) { if (a== 1) return 1; else if (a==2) return 3; else return (f(a-1) + f(a-2)); } //end of function void main () { int n; printf ("Enter n:\n"); scanf ("%d", &n); printf("%d", f(n)); }
answer:18
===========================================
answer:4Code:#include<stdio.h> int myfunction(int p, int q) { if (p == q) return p; else if (p < q) return myfunction(q - p, p); else return myfunction(p - q, q); } void main() { int result; result=myfunction(20,4); printf("%d",result); }
my question is how to get the answer????



LinkBack URL
About LinkBacks



I used to be an adventurer like you... then I took an arrow to the knee.