1
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 ____
2
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 ____
3
GATE CSE 2019
MCQ (Single Correct Answer)
+2
-0.67
Consider the following C function.
void convert(int n){
if(n < 0)
printf("%d",n);
else {
convert(n/2);
printf("%d",n%2);
}
}
Which one of the following will happen when the function convert is called with any positive integer n as argument?
4
GATE CSE 2019
MCQ (Single Correct Answer)
+2
-0.67
Consider the following C program :
#include<stdio.h>
int r()
{
static int num=7;
return num--;
}
int main()
{
for(r();r();r())
printf("%od ",r());
return 0;
}
Which one of the following values will be displayed on execution of the programs?
GATE CSE Subjects
Browse all chapters by subject
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