1
GATE CSE 2021 Set 1
Numerical
+2
-0
Consider the following ANSI C function:
int SimpleFunction (int y[], int n, int x)
{
int total = y[0], loopIndex;
for (loopIndex = 1; loopIndex <= n - 1; loopIndex++)
total = x * total + y[loopIndex];
return total :
}
Let Z be an array of 10 elements with Z[i] = 1, for all i such that 0 ≤ i ≤ 9. The value returned by SimpleFunction (Z, 10, 2) is ______
Your input ____
2
GATE CSE 2020
Numerical
+2
-0
Consider the following C functions.
___________________
The return value of fun2 (5) is _______.
int fun1 (int n) {
static int i = 0;
if (n > 0) {
++i;
fun1(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 _______.
Your input ____
3
GATE CSE 2020
Numerical
+2
-0
Consider the following C functions.
____________________
The value returned by pp (3, 4) is ________.
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 ________.
Your input ____
4
GATE CSE 2018
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C code. Assume that unsigned long int type length is 64
bits.
unsigned long int fun(unsigned long int n){
unsigned long int i, j = 0, sum = 0;
for (i = n; i > 1; i = i/2) j++;
for ( ; j > 1; j = j/2) sum++;
return(sum);
}
The value returned when we call fun with the input $${2^{40}}$$ isQuestions Asked from Function and Recursion (Marks 2)
Number in Brackets after Paper Indicates No. of Questions
GATE CSE 2024 Set 1 (1)
GATE CSE 2022 (1)
GATE CSE 2021 Set 2 (1)
GATE CSE 2021 Set 1 (2)
GATE CSE 2020 (2)
GATE CSE 2018 (1)
GATE CSE 2015 Set 2 (1)
GATE CSE 2012 (1)
GATE CSE 2011 (2)
GATE CSE 2008 (1)
GATE CSE 2007 (1)
GATE CSE 2005 (2)
GATE CSE 2004 (2)
GATE CSE 2003 (1)
GATE CSE 2002 (1)
GATE CSE 2000 (1)
GATE CSE 1999 (1)
GATE CSE 1998 (2)
GATE CSE 1995 (1)
GATE CSE 1993 (1)
GATE CSE Subjects
Theory of Computation
Operating Systems
Algorithms
Database Management System
Data Structures
Computer Networks
Software Engineering
Compiler Design
Web Technologies
General Aptitude
Discrete Mathematics
Programming Languages