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

GATE 2004

199 questions

MCQ 1991-mark 199

Questions 91–95 of 199

Q91Function1 markMCQ−0.33 if wrong
What is the output of the following program?
#include <stdio.h>
int funcf (int x);
int funcg (int y);
main ()
{
    int x = 5, y = 10, count;
    for (count = 1; count <= 2; ++count) {
        y += funcf(x) + funcg(x);
        printf ("%d", y);
    }
}
funcf (int x) {
    int y;
    y = funcg(x);
    return (y);
}
funcg (int x) {
    static int y = 10;
    y += 1;
    return (y + x);
}
 

Q92Function1 markMCQ−0.33 if wrong
Consider the following C function:
 int f(int n)
{
   static int i = 1;
   if (n >= 5)
      return n;
   n = n+i;
   i++;
   return f(n);
}
The value returned by f(1) is

Q93Function1 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.

Q94Array and Pointer1 markMCQ−0.33 if wrong
Consider the following C program which is supposed to compute the transpose of a given 4×44 \times 4 matrix M. Note that, there is an X in the program which indicates some missing statements. Choose the correct option to replace X in the program.
 #include <stdio.h>
#define ROW 4
#define COL 4
int M[ROW][COL] = {1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16};
main()
{
    int i, j, t;
    for (i = 0; i < 4; ++i)
    {
        X
    }
    for (i = 0; i < 4; ++i)
        for (j = 0; j < 4; ++j)
            printf ("%d", M[i][j]);
}

Q95Array and Pointer1 markMCQ−0.33 if wrong
Consider the following C program segment:
char p[20];
char *s = "string";
int length = strlen(s);
int i;
for (i = 0; i < length; i++)
     p[i] = s[length - i];
printf("%s",p); 
The output of the program is