This set of C Multiple Choice Questions & Answers (MCQs) focuses on “Pointers Vs. Multi-dimensional Arrays – 2”.
Pre-requisite for this C MCQ set: Advanced C Programming Video Tutorial.
1. What will be the output of the following C code (considering sizeof char is 1 and pointer is 4)?
#include <stdio.h>
int main()
{
char *a[2] = {"hello", "hi"};
printf("%d", sizeof(a));
return 0;
}
a) 9
b) 4
c) 8
d) 10
View Answer
Explanation: None.
2. What will be the output of the following C code?
#include <stdio.h>
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%d", sizeof(a));
return 0;
}
a) 9
b) 12
c) 8
d) 10
View Answer
Explanation: None.
3. What will be the output of the following C code?
#include <stdio.h>
int main()
{
char a[2][6] = {"hello", "hi"};
printf("%s", *a + 1);
return 0;
}
a) hello
b) hi
c) ello
d) ello hi
View Answer
Explanation: None.
4. What will be the output of the following C code?
#include <stdio.h>
int main()
{
char *a[2] = {"hello", "hi"};
printf("%s", *(a + 1));
return 0;
}
a) hello
b) ello
c) hi
d) ello hi
View Answer
Explanation: None.
5. What is the advantage of a multidimensional array over pointer array?
a) Predefined size
b) Input can be taken from user
c) Faster Access
d) All of the mentioned
View Answer
Explanation: None.
6. Which of the following operation is possible using a pointer char? (Assuming the declaration is char *a;)
a) Input via %s
b) Generation of the multidimensional array
c) Changing address to point at another location
d) All of the mentioned
View Answer
Explanation: None.
7. Comment on the following two operations.
int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1 int b[4][4] = {{1, 2, 3}, {1, 2, 3, 4}};//- 2
a) 1 will work, 2 will not
b) 1 and 2, both will work
c) 1 won’t work, 2 will work
d) Neither of them will work
View Answer
Explanation: None.
8. Comment on the following two operations.
int *a[] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 1 int b[][] = {{1, 2, 3}, {1, 2, 3, 4}}; //- 2
a) 1 works, 2 doesn’t
b) 2 works, 1 doesn’t
c) Both of them work
d) Neither of them work
View Answer
Explanation: None.
Sanfoundry Global Education & Learning Series – C Programming Language.
To practice all areas of C language, here is complete set of 1000+ Multiple Choice Questions and Answers.
- Apply for Computer Science Internship
- Check Computer Science Books
- Practice BCA MCQs
- Practice Computer Science MCQs
- Check C Books