Function: GATE CS Previous Year Questions

Function · Programming in C

68 questions · asked in 26 of 27 years (2000–2026)

MCQ 47 · NAT 211-mark 35 · 2-mark 33

2000Questions per year2026

Questions 61–65 of 68

Q61GATE 20041 markMCQ−0.33 if wrong
Consider the following C function
 void swap (int a, int b)
{
   int temp;
   temp = a;
   a = b;
   b = temp;
}
In order to exchange the values of two variables x and y.

Q62GATE 20031 markMCQ−0.33 if wrong
Consider the C program shown below.
  #include <stdio.h> 
#define print(x) printf("%d ", x)
int x;
void Q(int z)
{
    z += x;
    print(z);
}
void P(int *y)
{
    int x = *y + 2;
    Q(x);
    *y = x - 1;
    print(x);
}
main(void)
{
    x = 5;
    P(&x);
    print(x);
}
The output of this program is

Q63GATE 20031 markMCQ−0.33 if wrong
The following program fragment is written in a programming language that allows 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

Q64GATE 20031 markMCQ−0.33 if wrong
The following program fragment is written in a programming language that allows 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 static scoping and call by need parameter passing mechanism, the values printed by the above program are

Q65GATE 20021 markMCQ−0.33 if wrong
The results returned by function under value-result and reference parameter passing conventions

Keep practising

Topics in Programming in C

All CS topics ›