C Programming Questions and Answers – Multidimensional Arrays – 1

This section on C MCQs (multiple choice questions) focuses on “Multidimensional Arrays”. One shall practice these MCQs to improve their C programming skills needed for various interviews (campus interviews, walkin interviews, company interviews), placements, entrance exams and other competitive exams. These questions can be attempted by anyone focusing on learning C Programming language. They can be a beginner, fresher, engineering graduate or an experienced IT professional. Our multiple choice questions come with detailed explanation of the answers which helps in better understanding of C concepts.

Here is a listing of C multiple choice questions on “Multidimensional Arrays” along with answers, explanations and/or solutions:

1. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int a[2][3] = {1, 2, 3, 4, 5};
  5.         int i = 0, j = 0;
  6.         for (i = 0; i < 2; i++)
  7.         for (j = 0; j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }

a) 1 2 3 4 5 0
b) 1 2 3 4 5 junk
c) 1 2 3 4 5 5
d) Run time error
View Answer

Answer:a

2. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void main()
  3.     {
  4.         int a[2][3] = {1, 2, 3, , 4, 5};
  5.         int i = 0, j = 0;
  6.         for (i = 0; i < 2; i++)
  7.         for (j = 0; j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }

a) 1 2 3 junk 4 5
b) Compile time error
c) 1 2 3 0 4 5
d) 1 2 3 3 4 5
View Answer

Answer:b

3. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f(int a[][3])
  3.     {
  4.         a[0][1] = 3;
  5.         int i = 0, j = 0;
  6.         for (i = 0; i < 2; i++)
  7.         for (j = 0; j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }
  10.     void main()
  11.     {
  12.         int a[2][3] = {0};
  13.         f(a);
  14.     }

a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
View Answer

Answer:a

4. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f(int a[][])
  3.     {
  4.         a[0][1] = 3;
  5.         int i = 0, j = 0;
  6.         for (i = 0;i < 2; i++)
  7.         for (j = 0;j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }
  10.     void main()
  11.     {
  12.         int a[2][3] = {0};
  13.         f(a);
  14.     }

a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
View Answer

Answer:c

5. What is the output of this C code?

  1.     #include <stdio.h>
  2.     void f(int a[2][])
  3.     {
  4.         a[0][1] = 3;
  5.         int i = 0, j = 0;
  6.         for (i = 0;i < 2; i++)
  7.         for (j = 0;j < 3; j++)
  8.         printf("%d", a[i][j]);
  9.     }
  10.     void main()
  11.     {
  12.         int a[2][3] = {0};
  13.         f(a);
  14.     }

a) 0 3 0 0 0 0
b) Junk 3 junk junk junk junk
c) Compile time error
d) All junk values
View Answer

Answer:c

6. Comment on the following statement:
    int (*a)[7];
a) An array “a” of pointers.
b) A pointer “a” to an array.
c) A ragged array.
d) None of the mentioned
View Answer

Answer:b

7. Comment on the 2 arrays regarding P and Q:
    int *a1[8];
    int *(a3[8]);
    P. Array of pointers
    Q. Pointer to an array
a) a1 is P, a2 is Q
b) a1 is P, a2 is P
c) a1 is Q, a2 is P
d) a1 is Q, a2 is Q
View Answer

Answer:b

8. Which of the following is not possible statically in C?
a) Jagged Array
b) Rectangular Array
c) Cuboidal Array
d) Multidimensional Array
View Answer

Answer:a

Sanfoundry Global Education & Learning Series – C Programming Language.

Here’s the list of Best Reference Books in C Programming Language.

To practice all features of C programming language, here is complete set of 1000+ Multiple Choice Questions and Answers on C.

If you liked this C MCQ, kindly share, recommend or like below!

Subscribe Newsletter & Posts
About

Manish Bhojasia, a technology veteran with 17+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below.


Sanfoundry Training Center of Excellence (CoE)

Manish Bhojasia, a technology veteran with 17+ years @ Cisco & Wipro, is Founder and CTO at Sanfoundry. He is Linux Kernel Developer and SAN Architect and is passionate about competency developments in these areas. He lives in Bangalore and delivers focused training sessions to IT professionals in Linux Kernel, Linux Debugging, Linux Device Drivers, Linux Networking, Linux Storage & Cluster Administration, Advanced C Programming, SAN Storage Technologies, SCSI Internals and Storage Protocols such as iSCSI & Fiber Channel. Stay connected with him below.

1000 C MCQs | Quiz

Variable Names - 1
Data Types and Sizes - 1
Constants - 1
Declarations - 1
Arithmetic Operators - 1
Relational & Logical Operators - 1
Type Conversions - 1
Increment and Decrement Operators - 1
Bitwise Operators - 1
Assigment Operators & Expressions - 1
Conditional Expressions - 1
Precedence and Order of Evaluation - 1
Precedence and Order of Evaluation - 2
Precedence and Order of Evaluation - 3
Variable Names - 2
Data Types and Sizes - 2
Constants - 2
Declarations - 2
Arithmetic Operators - 2
Relational & Logical Operators - 2
Type Conversions - 2
Increment and Decrement Operators - 2
Bitwise Operators - 2
Assigment Operators & Expressions - 2
Conditional Expressions - 2
Precedence and Order of Evaluation - 4
Precedence and Order of Evaluation - 5
Precedence and Order of Evaluation - 6
If-then-else Statements - 1
Switch Statements - 1
For Loops - 1
While Loops - 1
Break and Continue - 1
Goto & Labels - 1
If-then-else Statements - 2
Switch Statements - 2
For Loops - 2
While Loops - 2
Break and Continue - 2
Goto & Labels - 2
Basics of Functions - 1
Functions Returning Non-integers - 1
External Variables - 1
Scope of a Variable - 1
Static Variables - 1
Register Variables - 1
Automatic Variables - 1
C-Preprocessor - 1
File Inclusion - 1
Macro Substitution - 1
Conditional Inclusion - 1
Basics of Functions - 2
Functions Returning Non-integers - 2
External Variables - 2
Scope of a Variable - 2
Static Variables - 2
Register Variables - 2
Automatic Variables - 2
C-Preprocessor - 2
File Inclusion - 2
Macro Substitution - 2
Conditional Inclusion - 2
Pointers and Addresses - 1
Pointers and Function Arguments - 1
Pointers and Arrays - 1
Address Arithmetic - 1
Character Pointers and Functions - 1
Pointers to Pointers - 1
Multidimensional Arrays - 1
Initialization of Pointer Arrays - 1
Pointers Vs. Multi-dimensional Arrays - 1
Command Line Arguments - 1
Pointers to Functions - 1
Complicated Declarations - 1
Pointers and Addresses - 2
Pointers and Function Arguments - 2
Pointers and Arrays - 2
Address Arithmetic - 2
Character Pointers and Functions - 2
Pointers to Pointers - 2
Multidimensional Arrays - 2
Initialization of Pointer Arrays - 2
Pointers Vs. Multi-dimensional Arrays - 2
Command Line Arguments - 2
Pointers to Functions - 2
Complicated Declarations - 2
Basics of Structures - 1
Structures and Functions - 1
Arrays of Structures - 1
Pointer to Structures - 1
Self-Referential Structures - 1
Table Lookup - 1
Typedefs - 1
Unions - 1
Bit-fields - 1
Basics of Structures - 2
Structures and Functions - 2
Arrays of Structures - 2
Pointer to Structures - 2
Self-Referential Structures - 2
Table Lookup - 2
Typedefs - 2
Unions - 2
Bit-fields - 2
Standard Input & Output - 1
Formatted Output - 1
Variable Length Argument - 1
Formatted Input - 1
File Access - 1
Error Handling - 1
Line Input & Output - 1
String Operations - 1
Character Class Testing & Conversions - 1
Ungetc - 1
Storage Management - 1
Mathematical Functions - 1
Random Number Generation - 1
Standard Input & Output - 2
Formatted Output - 2
Variable Length Argument - 2
Formatted Input - 2
File Access - 2
Error Handling - 2
Line Input & Output - 2
String Operations - 2
Character Class Testing & Conversions - 2
Ungetc - 2
Storage Management - 2
Mathematical Functions - 2
Random Number Generation - 2
Float Datatype - 1
Sizeof - 1
Float Datatype - 2
Sizeof - 2
Subscribe Newsletter & Posts
Follow Manish & Sanfoundry