Top

Arrays

21.

What is the output of the following piece of code?

public class array
{
 public static void main(String args[])
 {
  int []arr = {1,2,3,4,5};
  System.out.println(arr[2]);
  System.out.println(arr[4]);
 }
}

 

Answer: A

Array indexing starts from 0.

Enter details here

Answer: D

No answer description available for this question.

Enter details here

23.

Consider an array consisting of –ve and +ve numbers. What would be the worst case time complexity of an algorithm to segregate the numbers having same sign altogether i.e all +ve on one side and then all -ve on the other ?

Answer: A

No answer description available for this question.

Enter details here

Answer: B

No answer description available for this question.

Enter details here

25.

The parameter passing mechanism for an array is

Answer: C

No answer description available for this question.

Enter details here

26.

What is the maximun number of dimensions an array in C may have?

Answer: D

The maximum size of an array is determined by the amount of memory that a program can access. On a 32-bit system, the maximum amount of memory that can be addressed by a pointer is 2^32 bytes which is 4 gigabytes. The actual limit may be less, depending on operating system implementation details.

Enter details here

27.

Predict the output of below code: 

#include

int main()
{
    int arr[1]={10};
    printf("%d\n", 0[arr]);
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

28.

What will be the size of above array element ?

int a[20]

 

Answer: C

No answer description available for this question.
 

Enter details here

29.

The following program

main()
{
  static char a[3][4] = {"abcd", "mnop", "fghi"};
  putchar(**a);
}

 

Answer: D

*a points to the string "abcd".**a is the first character of "abcd", which is the character 'a '

Enter details here

30.

Pick out the output

#include 
    int main()
    {
        foo(ary);
    }
    void foo(int **ary)
    {
        int i = 10, k = 10, j = 2;
        int *ary[2];
        ary[0] = &i;
        ary[1] = &j;
        printf("%d\n", ary[0][1]);
    }

 

Answer: D

No answer description available for this question.

Enter details here

Loading…
Tags: Arrays Questions and Answers || Arrays MCQ Questions and Answers || Arrays GK Questions and Answers || Arrays GK MCQ Questions || Arrays Multiple Choice Questions and Answers || Arrays GK || GK on Arrays || C Programming Questions and Answers || C Programming MCQ Questions and Answers || C Programming GK Questions and Answers || GK on C Programming