C-Programming |Gate-2020|
1. Consider the following C functions.
int fun1 (int n)
static int i=0;
if(n>0)
{
{
++i;
fun (n-1);
}
return(i);
}
int fun2(int n)
static int i=0;
if(n>0)
i= i+fun1()n;
fun2(n-1);
}
return(i);
}
The return value of fun2 (5) is _______. [GATE – 2020]
a. 55
b. 54
c. 56
d. 57
Answer : a)
C-Programming |Gate-2020|
2. Consider the following C functions.
int tob (int b, int*arr)
{
int i;
for (i=0; b>0;i++)
{
if(b%2)
arr[i]=1;
else
arr[i]=0;
b=b/2;
}
return(i);
}
int pp (int a, int b)
{
int arr[20]
int i, tot=1, ex, len;
ex =a;
len = tob (b,arr);
for(i=0;i<len;i++)
{
if(arr[i]==1)
tot = tot* ex;
ex = ex*ex;
}
return (tot);
}
The value returned by pp (3, 4) is ________. [GATE – 2020]
a. 80
b. 81
c. 82
d. 83
Answer : b)
OS – GATE Previous Year Questions
DS – GATE Previous Year Questions