1
GATE CSE 2007
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C function:
int f(int n)
{
static int r = 0;
if(n <= 0) return 1;
if(n>3)
{
r = n;
return f(n-2)+2;
}
return f(n-1)+r;
}
What is the value of f(5)?
2
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
void foo (int n, int sum) {
int k = 0, j = 0;
if(n==0) return;
k=n%10; j = n /10;
sum = sum + k;
foo(j, sum);
printf("%d",k);
}
int main () {
int a = 2048, sum = 0;
foo(a, sum);
printf("%d\n", sum);
}
What does the above program print?3
GATE CSE 2005
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C program:
double foo(double); /* Line 1 */
int main () {
double da, db;
//input da
db = foo(da);
}
double foo(double a){
return a;
}
The above code compiled without any error or warning. If Line 1 is deleted, the above code will show:4
GATE CSE 2004
MCQ (Single Correct Answer)
+2
-0.6
Consider the following C function:
int f(int n)
{
static int i = 1;
if(n>=5) return n;
n = n+1;
i++;
return f(n);
}
The value returned by f(1) 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