1
GATE CSE 2014 Set 2
+2
-0.6
Consider the C function given below.
int f(int j)
{
static int i = 50;
int k;
if (i == j)
{
printf("something");
k = f(i);
return 0;
}
else return 0;
}
Which one of the following is TRUE?
A
The function returns 0 for all values of j.
B
The function prints the string something for all values of j.
C
The function returns 0 when j = 50.
D
The function will exhaust the runtime stack or run into an infinite loop when j = 50.
2
GATE CSE 2013
+2
-0.6
What is the return value of f (p, p), if the value of p is initialized to 5 before the call? Note that the first parameter is passed by reference, whereas the second parameter is passed by value.
int f (int &x, int c) {
c = c - 1;
if (c==0) return 1;
x = x + 1;
return f(x,c) * x;
}
A
3024
B
6561
C
55440
D
161051
3
GATE CSE 2008
+2
-0.6
Which of the following are true?

I. A programming language which does not permit global variables of any kind and has no nesting of procedures/functions, but permits recursion can be implemented with static storage allocation

II. Multi-level access link (or display) arrangement is needed to arrange activation records only if the programming language being implemented has nesting of procedures/functions

III. Recursion in programming languages cannot be implemented with dynamic storage allocation

IV. Nesting procedures/functions and recursion require a dynamic heap allocation scheme and cannot be implemented with a stack-based allocation scheme for activation records

V. Programming languages which permit a function to return a function as its result cannot be implemented with a stack-based storage allocation scheme for activation records

A
II and V only
B
I, III and IV only
C
I, II and V only
D
II, III and V only
4
GATE CSE 2003
+2
-0.6
The following program fragment is written in a programming language that allows global variables and does not allow nested declarations of functions.
global int i = 100, j = 5;
void P(x) {
int i = 10;
print(x + 10);
i = 200;
j = 20;
print (x);
}
main() {
P(i + j);
}
If the programming language uses dynamic scoping and call by name parameter passing mechanism, the values printed by the above program are
A
115, 220
B
25, 220
C
25, 15
D
115, 105
GATE CSE Subjects
Discrete Mathematics
Programming Languages
Theory of Computation
Operating Systems
Digital Logic
Computer Organization
Database Management System
Data Structures
Computer Networks
Algorithms
Compiler Design
Software Engineering
Web Technologies
General Aptitude
EXAM MAP
Joint Entrance Examination
{"ft_lang_label":"__label__en","ft_lang_prob":0.82889,"math_prob":0.89722794,"size":1308,"snap":"2023-40-2023-50","text_gpt3_token_len":310,"char_repetition_ratio":0.11886503,"word_repetition_ratio":0.026666667,"special_character_ratio":0.25993884,"punctuation_ratio":0.11336032,"nsfw_num_words":0,"has_unicode_error":false,"math_prob_llama3":0.97676283,"pos_list":[0],"im_url_duplicate_count":[null],"WARC_HEADER":"{\"WARC-Type\":\"response\",\"WARC-Date\":\"2023-09-29T21:27:35Z\",\"WARC-Record-ID\":\"<urn:uuid:e9f6e49c-f73a-4b40-805f-978eb966633b>\",\"Content-Length\":\"212249\",\"Content-Type\":\"application/http; msgtype=response\",\"WARC-Warcinfo-ID\":\"<urn:uuid:b44e1c35-cb79-4696-bde3-1eb2bc5a68d2>\",\"WARC-Concurrent-To\":\"<urn:uuid:ea8e1511-699e-4d94-a45c-446a4014e2d2>\",\"WARC-IP-Address\":\"104.21.4.127\",\"WARC-Target-URI\":\"https://questions.examside.com/past-years/gate/question/consider-the-c-function-given-belowint-fint-j-static-int-i-5-gate-cse-2014-set-2-marks-2-rrcucykcvc4g1ewm.htm\",\"WARC-Payload-Digest\":\"sha1:RBVOZ3RUVPFL72YAYSKGXI5NYZ23Z4QS\",\"WARC-Block-Digest\":\"sha1:4AISK4DGRLQMAVDBA6SEEBKJZBJIAZE7\",\"WARC-Identified-Payload-Type\":\"text/html\",\"warc_filename\":\"/cc_download/warc_2023/CC-MAIN-2023-40/CC-MAIN-2023-40_segments_1695233510528.86_warc_CC-MAIN-20230929190403-20230929220403-00865.warc.gz\"}"}