Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

GATE | Gate IT 2008 | Question 50

  • Difficulty Level : Hard
  • Last Updated : 28 Jun, 2021

C program is given below:

Attention reader! Don’t stop learning now.  Practice GATE exam well before the actual exam with the subject-wise and overall quizzes available in GATE Test Series Course.

Learn all GATE CS concepts with Free Live Classes on our youtube channel.

# include <stdio.h>
int main ()
        int i, j;
        char a [2] [3] = {{'a', 'b', 'c'}, {'d', 'e', 'f'}};
        char b [3] [2];
        char *p = *b;
        for (i = 0; i < 2; i++) {
              for (j = 0; j < 3; j++) {
              *(p + 2*j + i) = a [i] [j];
 /* Add code here. Remove these lines if not writing code */ 

What should be the contents of the array b at the end of the program?
(A) a b
c d
e f
(B) a d
b e
c f
(C) a c
e b
d f
(D) a e
d c
b f

Answer: (B)

Explanation: *p= a[0][0]
*(p+2) = a[0][1]
*(p+4) = a[0][2]
*(p+1) = a[1][0]
*(p+3) = a[1][1]
*(p+5) = a[1][2]

Quiz of this Question

My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!