# C-Programming |Gate-2008| previous year questions| Set-12

C-Programming |Gate-2008|

1. Which combination of the integer variables x, y and z makes the variable a get the value 4 in the following expression? a = (x > y)? ((x > z)? x : z): ((y > z)? y : z) [GATE – 2008]

a. x = 3, y = 4, z = 2
b. x = 6, y = 5, z = 3
c. x = 6, y = 3, z = 5
d. x = 5, y = 4, z = 5

2. What is printed by the following C program?
int f (int x, int * py, int * *ppz)
void main ( )
{
{ int y,    z;
int   c,   * b,      * *a; * *ppz  +  = 1;  z = *ppz;
c = 4;     b = &c;  a = &b; * py  + = 2;   y = *py;
pr int f (” %d”, f (c, b, a)); x  + = 3;
}
return x + y + z;
} [GATE – 2008]

a. 18
b. 19
c. 20
d. 21

3. Choose the correct option to fill ? 1 and ? 2 so that the program below prints an input string in reverse order. Assume that the input string is terminated by a newline void recerse (void){ int c; if (?1)reverse ( ); ? 2 } main ( ) { pr int f (“Enter Text “); pr int f (“\ n “); reverse ( );pr int f (“\ n “); } [GATE – 2008]

a. ?1 is (getchar( ) != ’\n’)
?2 is getchar(c);

b. ?1 is (c = getchar( ) ) != ’\n’)
?2 is getchar(c);

c. ?1 is (c != ’\n’)
?2 is putchar(c);

d. ?1 is ((c = getchar()) != ’\n’)
?2 is putchar(c);

4. Match the programming paradigms and languages given in the following table. [GATE – 2008]

a. I-c, II-d, III-b, IV-a
b. I-a, II-d, III-c, IV-b
c. I-d, II-c, III-b, IV-a
d. I-c, II-d, III-a, IV-b

5. What is the output printed by the following C code? [GATE – 2008]

a. Dlrow
b. Null String
c. Dlrld
d. worow

6. Consider the C program below. What does it print? [GATE – 2008]

a. 5,5
b. 5,4
c. 4,5
d. 4,4

7. Consider the C program given below. What does it print? [GATE – 2008]

a. 2,3
b. 2,4
c. 3,2
d. 3,3

8. C program is given below:

What should be the contents of the array b at the end of the program? [GATE – 2008]

a. ab
cd
ef

be
cf

c. ac
eb
df

d. ae
dc
bf

9. Consider the code fragment written in C below :

What does f(173) print? [GATE – 2008]

a. 010110101
b. 010101101
c. 10110101
d. 10101101

10. Consider the code fragment written in C below : [GATE – 2008]

Which of the following implementations will produce the same output for f(173) as the above code? P1

P2

a. Both P1 and P2
b. P2 only
c. P1 only
d. Neither P1 nor P2