C Programming GATE CS and IT previous year questions with Answer


Ques 41 Gate 2015 Set-2


Consider the following function written in the C programming language.

void foo (char *a)
{
    if (*a && *a != ` `)
    {
        foo(a+1);
        putchar(*a);
    }
}


The output of the above function on input “ABCD  EFGH” is

A

ABCD EFGH

B

ABCD

C

HGFE DCBA

D

DCBA



Ques 42 Gate 2015 Set-1


The output of the following C program is __________.

void f1 (int a, int b)
{
    int c;
    c=a; a=b; b=c;
}
void f2 (int *a, int *b)
{
    int c;
   c=*a; *a=*b;*b=c;
}
int main()
{
    int a=4, b=5, c=6;
    f1(a, b);
    f2(&b, &c);
    printf (“%d”, c-a-b);
    return 0;
}


a is the correct answer.


Ques 43 Gate 2015 Set-1


Which of following statements is/are False?

I. XML overcomes the limitations in HTML to support a structured way of organizing content.
II. XML specification is not case sensitive while HTML specification is case sensitive.
III. XML supports user defined tags while HTML uses pre-defined tags.
IV. XML tags need not be closed while HTML tags must be closed.

A

II only

B

I only

C

I and IV only

D

III and IV only



Ques 44 Gate 2014 Set-1


Consider the following program in C language:

#include <stdio.h>
main()
{
    int i;
    int *pi = &i;
    scanf("%d", pi);
    printf("%d∖n", i+5);
}


Which one of the following statements is TRUE?

A

Compilation fails.

B

Execution results in a run-time error.

C

On execution, the value printed is 5 more than the address of variable i.

D

On execution, the value printed is 5 more than the integer value entered.