Consider the C program given below. What does it print? #include <stdio.h> int…

GATE · 2008 · IT

Consider the C program given below. What does it print?

#include <stdio.h>
int main ()
{
        int i, j;
        int a [8] = {1, 2, 3, 4, 5, 6, 7, 8};
        for(i = 0; i < 3; i++) {
             a[i] = a[i] + 1;
             i++;
        }
        i--;
        for (j = 7; j > 4; j--) {
              int i = j/2;
              a[i] = a[i] - 1;
        }
        printf ("%d, %d", i, a[i]);
}

  1. A.

    2, 3

  2. B.

    2, 4

  3. C.

    3, 2

  4. D.

    3, 3

Attempted by 83 students.

Sign up free to check your answer

Sign up free

Explore the full course: Gate Guidance By Sanchit Sir

Loading lesson…