0% found this document useful (0 votes)
23 views

arrays-mcq-1 (1)

This document contains a series of multiple-choice questions (MCQs) focused on arrays and pointers in the C programming language. Each question tests knowledge on array definitions, outputs of specific C programs, and characteristics of arrays and pointers. The document serves as a quiz or study guide for individuals looking to assess or enhance their understanding of these concepts in C.

Uploaded by

sandyyashraff595
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
23 views

arrays-mcq-1 (1)

This document contains a series of multiple-choice questions (MCQs) focused on arrays and pointers in the C programming language. Each question tests knowledge on array definitions, outputs of specific C programs, and characteristics of arrays and pointers. The document serves as a quiz or study guide for individuals looking to assess or enhance their understanding of these concepts in C.

Uploaded by

sandyyashraff595
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 11

Mcq on arrays and pointers

1) What is an Array in C language.?


A) A group of elements of same data type.
B) An array contains more than one element
C) Array elements are stored in memory in continuous or contiguous
locations.
D) All the above.

2) Choose a correct statement about C language arrays.


A) An array address is the address of first element of array itself.
B) An array size must be declared if not initialized immediately.
C) Array size is the sum of sizes of all elements of the array.
D) All the above
3) What are the Types of Arrays.?
A) int, long, float, double
B) struct, enum
C) char
D) All the above

4) An array Index starts with.?


A) -1
B) 0
C) 1
D) 2
5) Choose a correct statement about C language arrays.
A) An array size can not changed once it is created.
B) Array element value can be changed any number of times
C) To access Nth element of an array students, use students[n-1] as the
starting index is 0.
D) All the above
6) What is the output of C Program.? int main() { int a[];
a[4] = {1,2,3,4}; printf("%d", a[0]); }
A) 1
B) 2
C) 4
D) Compiler error

7) What is the output of C Program.? int main() { int a[] =


{1,2,3,4}; int b[4] = {5,6,7,8}; printf("%d,%d", a[0],
b[0]); }
A) 1,5
B) 2,6
C) 0 0
D) Compiler error
8) What is the output of C Program.? int main() { char
grade[] = {'A','B','C'}; printf("GRADE=%c, ", *grade);
printf("GRADE=%d", grade); }
A) GRADE=some address of array, GRADE=A
B) GRADE=A, GRADE=some address of array
C) GRADE=A, GRADE=A
D) Compiler error

9) What is the output of C program.? int main() { char


grade[] = {'A','B','C'}; printf("GRADE=%d, ", *grade);
printf("GRADE=%d", grade[0]); }
A) A A
B) 65 A
C) 65 65
D) None of the above
10) What is the output of C program.? int main() { float
marks[3] = {90.5, 92.5, 96.5}; int a=0; while(a<3) {
printf("%.2f,", marks[a]); a++; } }
A) 90.5 92.5 96.5
B) 90.50 92.50 96.50
C) 0.00 0.00 0.00
D) Compiler error
11) What is the output of C Program.? int main() { int a[3]
= {10,12,14}; a[1]=20; int i=0; while(i<3) { printf("%d ",
a[i]); i++; } }
A) 20 12 14
B) 10 20 14
C) 10 12 20
D) Compiler error

12) What is the output of C program.? int main() { int a[3]


= {10,12,14}; int i=0; while(i<3) { printf("%d ", i[a]);
i++; } }
A) 14 12 10
B) 10 10 10
C) 10 12 14
D) None of the above
13) What is the output of C Program.? int main() { int a[3]
= {20,30,40}; a[0]++; int i=0; while(i<3) { printf("%d ",
i[a]); i++; } }
A) 20 30 40
B) 41 30 20
C) 21 30 40
D) None of the above

14) What is the output of C program with arrays.? int main()


{ int a[3] = {20,30,40}; int b[3]; b=a; printf("%d", b[0]);
}
A) 20
B) 30
C) address of 0th element.
D) Compiler error
15) What is the output of C Program with arrays and
pointers.? int main() { int a[3] = {20,30,40}; int (*p)[3];
p=&a; printf("%d", (*p)[0]); }
A) 20
B) 0
C) address of element 20
D) Compiler error
16) What is the output of C program with arrays and
pointers.? int main() { int a[3] = {20,30,40}; int *p[3];
p=&a; printf("%d", *p[0]); }
A) 20
B) address of element 20
C) Garbage value
D) Compiler error

17) What is the output of C program with arrays and


pointers.? int main() { int a[3] = {20,30,40}; printf("%d",
*(a+1)); }
A) 20
B) 30
C) 40
D) Compiler error

18) What is an array Base Address in C language.?


A) Base address is the address of 0th index element.
B) An array b[] base address is &b[0]
C) An array b[] base address can be printed with printf("%d", b);
D) All the above
19) What is the output of C Program with arrays and
pointers.? void change(int[]); int main() { int a[3] =
{20,30,40}; change(a); printf("%d %d", *a, a[0]); } void
change(int a[]) { a[0] = 10; }
A) 20 20
B) 10 20
C) 10 10
D) 20 30
20) An entire array is always passed by ___ to a called
function.
A) Call by value
B) Call by reference
C) Address relocation
D) Address restructure

21) 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

22) 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

23) 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

24) 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

25) 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.

26) 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.

27) 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
28) 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

29) 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.

30) 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

31) 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
32) What is the output of C Program with arrays.?
int main()
{
int ary[] = {1, 3, 5};
printf("%d %d", ary[-1], ary[4]);
return 0;
}

A) 1 5
B) 0 0
C) Compiler error
D) None of the above

33) What is the output of C Program with arrays.?


int main()
{
static int ary[] = {1, 3, 5};
printf("%d %d", ary[-1], ary[5]);
return 0;
}

A) 0 0
B) -1 -1
C) Compiler error
D) None of the above

34) What is the output of C Program with arrays and


pointers.?
int main()
{
int ary[] = {11, 33, 55};
int *p, *q;
p = ary;
q = ary+2;
printf("%d %d",*p, *q);
return 0;
}

A) 11 55
B) 11 13
C) 11 33
D) Compiler error

35) Array of Arrays is also called.?


A) Multi Data Array
B) Multi Size Array
C) Multi Dimensional Array
D) Multi Byte Array
36) What is the output of C program with multidimensional
arrays.?
int main()
{
int ary[3][] = {6,5,4,3,2,1};
printf("%d %d", ary[0][0], ary[2][1]);
return 0;
}

A) 6 1
B) 6 2
C) 5 1
D) Compiler error
37) Choose an alternative definition of C Multidimensional
array.?
int ary[][3] = {6,5,4,3,2,1};

A) int ary[2][3] = {6,5,4,3,2,1};


B) int ary[2][3] = {{6,5,4},{3,2,1}};
C) int ary[][3] = {{6,5,4},{3,2,1}};
D) All the above.

38) What is the output of C Program.?


int main()
{
int ary[2][2][3] = {
{{1,2,3},{4,5,6}},
{{7,8,9},{10,11,12}}
};
printf("%d",*(*(*(ary+1)+ 1)+2));
return 0;
}

A) 10
B) 11
C) 12
D) Compiler error

38) Choose a correct C Statement to choose number 66 in the


array, int ary[3][2] = {{11,22},{33,44},{55,66}};
A) ary[2][1]
B) *(*(ary+2)+1)
C) *ary[2]+1
D) All the above

39) A multidimensional array of dimension N is a collection


of.?
A) Single Dimensional Arrays
B) N dimensional arrays
C) N-1 dimension arrays
D) N-2 dimension arrays

40) Choose a correct statement about a Multidimensional


array and pointer.?
A) int *ptr[N] is an array of N integer pointers. Size is N * sizeof(1*int).
B) int (*ptr)[N] is a pointer to an array of N elements. Size of ptr is size of 1 integer.
C) An multidimensional array or a single dimensional array can contain pointer
elements.
D) All the above

You might also like