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

GATE 2006

191 questions

MCQ 1911-mark 191

Questions 91–95 of 191

Q91Function1 markMCQ−0.33 if wrong
The following function computes the value of (mn)\binom{m}{n} correctly for all legal values mm and nn (m≥1,n≥0 and m>n)(m \geq 1, n \geq 0 \text{ and } m \gt n)
 int func(int m, int n)
{
    if (E) return 1;
    else return(func(m -1, n) + func(m - 1, n - 1));
}
In the above function, which of the following is the correct expression for E?

Q92Function1 markMCQ−0.33 if wrong
Which one of the choices given below would be printed when the following program is executed?
#include <stdio.h>
void swap (int *x, int *y)
{
    static int *temp;
    temp = x;
    x = y;
    y = temp;
}
void printab ()
{
    static int i, a = -3, b = -6;
    i = 0;
    while (i <= 4)
    {
        if ((i++)%2 == 1) continue;
        a = a + i;
        b = b + i;
    }
    swap (&a, &b);
    printf("a =  %d, b = %d\n", a, b);
}
main()
{
    printab();
    printab();
} 

Q93Function1 markMCQ−0.33 if wrong
Consider the following code written in a pass-by reference language like FORTAN and these statements about the code.
subroutine swap(ix,iy)
     it = ix
L1 : ix = iy
L2 : iy = it
end
  ia = 3
  ib = 8
  call swap (ia, ib+5)
  print *, ia, ib
end 
S1: The complier will generate code to allocate a temporary nameless cell, initialize it to 13, and pass the address of the cell to swap
S2: On execution the code will generate a runtime error on line L1
S3: On execution the code will generate a runtime error on line L2
S4: The program will print 13 and 8
S5: The program will print 13 and -2
Exactly the following set of statement (s) is correct:

Q94Array and Pointer1 markMCQ−0.33 if wrong
Which one of the choices given below would be printed when the following program is executed?
 #include <stdio.h>
int a1[] = {6, 7, 8, 18, 34, 67};
int a2[] = {23, 56, 28, 29};
int a3[] = {-12, 27, -31};
int *x[] = {a1, a2, a3};
void print(int *a[])
{
    printf("%d,", a[0][2]);
    printf("%d,", *a[2]);
    printf("%d,", *++a[0]);
    printf("%d,", *(++a)[0]);
    printf("%d\n", a[-1][+1]);
}
main()
{
     print(x);
}

Q95Array and Pointer1 markMCQ−0.33 if wrong
Which one of the choices given below would be printed when the following program is executed ?
 #include <stdio.h>
struct test {
               int i;
               char *c;
}st[] = {5, "become", 4, "better", 6, "jungle", 8, "ancestor", 7, "brother"};
main ()
{ 
    struct test *p = st;
    p += 1;
    ++p -> c;
    printf("%s,", p++ -> c);
    printf("%c,", *++p -> c);
    printf("%d,", p[0].i);
    printf("%s \n", p -> c);
}