C MCQ Questions and Answers on Arrays and Pointers 2

Image

Study C MCQ Questions and Answers on Arrays, Multidimensional Arrays and Pointers. Easily attend technical interviews after reading these Multiple Choice Questions.

Go through C Theory Notes on Arrays before studying questions.



1) What is the output of C program with arrays and pointers.?
int main()
{
    int size=4;
    int a[size];
    a[0]=5;a[1]=6;
    a[2]=7;a[3]=8;
    printf("%d %d", *(a+2), a[1]);
}
A) 8 6
B) 7 6
C) 6 6
D) Compiler error
Answer [=]
Answer[=]
2) What is the output of C program with arrays.?
int main()
{
    int ary(3)=[20,30,40];
    printf("%d", a(1));
}
A) 20
B) 30
C) 0
D) Compiler error
Answer [=]
Answer[=]
3) What is the output of C Program with arrays.?
int main()
{
    int rollno[3]=[1001,1002,1003];
    printf("%d", rollno[1]);
}
A) 1002
B) 1003
C) address of 1002
D) Compiler error
Answer [=]
Answer[=]
4) What is the output of C program with arrays.?
int main()
{
   char grade={'A','B','C'};
   printf("%c", grade[0]);
}
A) A
B) B
C) C
D) Compiler error
Answer [=]
Answer[=]
5) What is the value of an array element which is not initialized.?
A) By default Zero 0
B) 1
C) Depends on Storage Class
D) None of the above.
Answer [=]
Answer[=]
6) What happens when you try to access an Array variable outside its Size.?
A) Compiler error is thrown
B) 0 value will be returned
C) 1 value will be returned
D) Some garbage value will be returned.
Answer [=]
Answer[=]
7) What is the size of an array in the below C program statement.?
int main()
{
    int ary[9];
    return 0;
}
A) 8
B) 9
C) 10
D) None of the above
Answer [=]
Answer[=]


 

8) What is the minimum and maximum Indexes of this below array.?
int main()
{
    int ary[9];
    return 0;
}
A) -1, 8
B) 0, 8
C) 1,9
D) None of the above
Answer [=]
Answer[=]
9) Can we change the starting index of an array from 0 to 1 in any way.?
A) Yes. Through pointers.
B) Yes. Through Call by Value.
C) Yes. Through Call by Reference.
D) None of the above.
Answer [=]
Answer[=]
10) What is the need for C arrays.?
A) You need not create so many separate variables and get confused while using.
B) Using a single Array variable, you can access all elements of the array easily.
C) Code maintainability is easy for programmers and maintainers.
D) All the above.
Answer [=]
Answer[=]
11) What is the output of C program with arrays.?
int main()
{
    int ary[4], size=4;
    printf("%d ", ary[size]);
    return 0;
}
A) 0
B) 1
C) Random number
D) Compiler error
Answer [=]
Answer[=]
12) What is the output of C Program with arrays.?
int main()
{
    int ary[4];
    ary[4] = {1,2,3,4};
    printf("%d ", ary[2]);
    return 0;
}
A) 2
B) 3
C) 0
D) Compiler error
Answer [=]
Answer[=]
13) What is the output of C Program with arrays.?
int main()
{
    int ary[3]={1,2};
    printf("%d %d",ary[2]);
    return 0;
}
A) 0
B) 2
C) Garbage value
D) Compiler error
Answer [=]
Answer[=]
14) What is a multidimensional array in C Language.?
A) It is like a matrix or table with rows and columns
B) It is an array of arrays
C) To access 3rd tow 2nd element use ary[2][1] as the index starts from 0 row or column
D) All the above.
Answer [=]
Answer[=]


 

15) If an integer array pointer is incremented, how many bytes will be skipped to reach next element location.?
A) 1
B) 2
C) 8
D) None of the above
Answer [=]
Answer[=]
16) What is the output of C Program with arrays and pointers.?
int main()
{
    int ary[] = {10,20,30}, *p;
    p = &ary[0];
    int i=0;
    while(i<3)
    {
        printf("%d ", *p);
        p++;
        i++;
    }
    return 0;
}
A) 10 10 10
B) 10 20 20
C) 10 20 30
D) randomvalue randomvalue randomvalue
Answer [=]
Answer[=]
17) What is the function used to allocate memory to an array at run time with Zero initial value to each.?
A) calloc()
B) malloc()
C) palloc()
D) kalloc()
Answer [=]
Answer[=]
18) What is the function used to allocate memory to an array at run time without initializing array elements.?
A) calloc()
B) malloc()
C) palloc()
D) kalloc()
Answer [=]
Answer[=]
19) Choose a correct Syntax for malloc() function to allocate memory to an array at run time.
A)
int *p;
p = (int*)malloc(10*sizeof(int));
B)
int *p;
p = (int*)malloc(10,sizeof(int));
C)
int *p;
p = (int*)malloc(sizeof(int), 10);
D)
int *p;
p = (int*)malloc(10*sizeof(int *));
Answer [=]
Answer[=]
20) What is the syntax of CALLOC to allocate memory to an array at runtime.?
A)
int *p;
p = (int*)calloc(10, sizeof(int));
B)
int *p;
p = (int*)calloc(10*sizeof(int));
C)
int *p;
p = (int*)calloc(sizeof(int), 10);
D)
int *p;
p = (int*)calloc(10, sizeof(int *));
Answer [=]
Answer[=]


Like or Share

Show some care. Like or Subscribe. [FB]...[Youtube]

C MCQ App by ExamTray 

Android APP

Java MCQ App by ExamTray 

Android APP
ALL MCQ App by ExamTray Android APP

Ad

 

Some good C Books

Book Price
1. C: The Complete Reference  Check Price
2. Let Us C Check Price
3. Programming in ANSI C Check Price
4. The C Programming Language Check Price

We may get some affiliate commission for the above purchases.