Top

Arrays

31.

Which of the following statements are correct about the program below?

#include

int main()
{
    int size, i;
    scanf("%d", &size);
    int arr[size];
    for(i=1; i<=size; i++)
    {
        scanf("%d", arr[i]);
        printf("%d", arr[i]);
    }
    return 0;
}

 

Answer: C

No answer description available for this question.

Enter details here

Answer: D

No answer description available for this question.

Enter details here

33.

What will be the output of the program ?

#include
void fun(int **p);

int main()
{
    int a[3][4] = {1, 2, 3, 4, 4, 3, 2, 8, 7, 8, 9, 0};
    int *ptr;
    ptr = &a[0][0];
    fun(&ptr);
    return 0;
}
void fun(int **p)
{
    printf("%d\n", **p);
}

 

Answer: A

No answer description available for this question.

Enter details here

Answer: B

Array contains elements only of the same type

Enter details here

Answer: B

No answer description available for this question.

Enter details here

36.

What will be the output of the program ?

#include

int main()
{
    float arr[] = {12.4, 2.3, 4.5, 6.7};
    printf("%d\n", sizeof(arr)/sizeof(arr[0]));
    return 0;
}

 

Answer: B

No answer description available for this question.

Enter details here

37.

Array can be considered as set of elements stored in consecutive memory locations but having __________.

Answer: A

Array store elements of same data type.

Enter details here

38.

If storage class is missing in the array definition, by default it will be taken to be 

Answer: A

No answer description available for this question.

Enter details here

39.

The following program

main( )
{
static int a[ ] = { 7, 8, 9 } ;
printf( "%d", 2[ a ] + a[ 2 ] ) ;
}

 

Answer: D

a[2] will be converted to *(a + 2).
*(a + 2) can as well be written as *(2 + a ) .
 *(2 + a ) is nothing but 2 [a] . So. a [2] is essentially same as 2 [a] which is same as * ( 2 + a ). So. it prints 9 + 9 = 18. Some of the modem compilers don't accept 2[a].

Enter details here

Answer: A

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