# GATE Questions & Answers of Arrays

## What is the Weightage of Arrays in GATE Exam?

Total 3 Questions have been asked from Arrays topic of Programming and Data Structures subject in previous GATE papers. Average marks 1.67.

Consider the following C program segment.

#include <stdio.h>
int main( )
{

char s1 = “1234”, *p;
p = s1 + 2;
*p = ‘0’;
printf (“%s”, s1);
}

What will be printed by the program?

##### Show Answer

Consider the following C program.

#include<stdio.h>
int main( )
{
static int a[ ] = {10, 20, 30, 40, 50};
static int *p[ ] = {a, a+3, a+4, a+1, a+2};
int **ptr = p;
ptr++;
printf(“%d%d”, ptr-p, **ptr);
}

The output of the program is ______.

##### Show Answer

Consider the following C function in which size is the number of elements in the array E:

int MyX(int *E, unsigned int size)
{
int Y = 0;
int Z;
int i, j, k;
for(i = 0; i < size; i++)
Y = Y + E[i];
for(i = 0; i < size; i++)
for(j = i; j < size; j++)
{
Z = 0;
for(k = i; k <= j; k++)
Z = Z + E[k];
if (Z > Y)
Y = Z;
}
return Y;
}

The value returned by the function MyX is the