GATE 2003 Computer Science and Information Technology (CS) Questions with Solutions

GATE 2003

107 questions

MCQ 1071-mark 107

Questions 51–55 of 107

Q51Pipeline Processor1 markMCQ−0.33 if wrong
For a pipelined CPU with a single ALU, consider the following situations
1. The (j + 1)-th instruction uses the result of j-th instruction as an operand
2. The execution of a conditional jump instruction
3. The j - th and j + 1 - st instructions require the ALU at the same time
Which of the above can cause a hazard?

Q52Loop1 markMCQ−0.33 if wrong
Consider the following C function.

float f(float x, int y)
{
  float p, s; int i;
  for (s=1, p=1, i=1; i < y; i ++)
  {
    p*= x/i;
    s+=p;
  }
  return s;
}  
For large values of y, the return value of the function f best approximates

Q53Function1 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

Q54Function1 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

Q55Function1 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