🚧 Site is under heavy maintenance.

Please come back later.

C Programming MCQs

Are you a BCA or CS Engineering student aiming to nail C programming?

You’ve landed in the perfect place! We’ve packed in over 330 handpicked MCQs covering everything you need to know about C programming. Whether you’re getting ready for exams, prepping for interviews, or just want to sharpen your skills, our question bank has got you covered.

Why Choose Our C Programming MCQs?

Our MCQs cover all the crucial topics in C programming, from the basics like data types and control structures to advanced concepts like pointers and memory management. Each question is crafted to test your knowledge and help you get fully prepared for any challenge.

Perfect for BCA and CS Engineering Students

This collection is made just for BCA and CS Engineering students, making it the ideal study resource for anyone pursuing a degree in computer science. The questions are aligned with what you’re learning in class, so you’re always on the right track.

Syllabus Overview

Unit I: Arrays
  • Definition, Declaration, and Initialization of One-Dimensional Arrays
  • Accessing and Displaying Array Elements
  • Sorting Techniques for Arrays
  • Interaction Between Arrays and Functions
  • Two-Dimensional Arrays: Declaration, Initialization, Accessing, Displaying, and Memory Representation (Row-Major and Column-Major Order)
  • Multidimensional Arrays
Unit II: Pointers
  • Introduction to Pointers: Definition, Declaration, and Initialization
  • Understanding the Indirection Operator and Address-of Operator
  • Performing Pointer Arithmetic
  • Dynamic Memory Allocation Using Pointers
  • Relationship Between Arrays and Pointers
  • Utilizing Pointers with Functions
Unit III: Strings
  • Definition, Declaration, and Initialization of Strings
  • Standard Library Functions for Strings: strlen, strcpy, strcat, strcmp
  • Implementing String Manipulation Functions Without Standard Library Support
Unit IV: Structures and Unions
  • Defining and Declaring Structures
  • Initializing Structure Variables
  • Accessing Structure Fields and Performing Operations on Structures
  • Nested Structures
  • Understanding Unions: Definition, Declaration, and Differentiation from Structures
Unit V: C Preprocessor and Bitwise Operations
  • Introduction to the C Preprocessor and Its Role
  • Macro Substitution Directives for Code Reusability
  • File Inclusion Directives for Incorporating External Code
  • Conditional Compilation Techniques
  • Bitwise Operators: AND, OR, XOR, NOT, Left Shift, Right Shift
  • Using Bit Masks for Data Manipulation
  • Introduction to Bit Fields
Unit VI: File Handling
  • Understanding Files and Their Role in Data Storage and Retrieval
  • Various File Opening Modes
  • Standard Library Functions for File Operations: fopen, fclose, feof, fseek, fewind
  • Working with Text Files Using fgetc, fputc, fscanf
  • Command-Line Arguments and Their Processing

Question: 1

âš 

How do you declare and initialize a one-dimensional character array with the string 'hello'?

  1. char arr[] = "hello";
  2. char arr[6] = {"h", "e", "l", "l", "o", "\0"};
  3. char arr[5] = "hello";
  4. Both A and B
Click to see the answer

Correct Answer: D. Both A and B

Explanation: A string in C can be initialized directly with double quotes, and a character array can be explicitly initialized with individual characters ending with a null terminator.

Question: 2

âš 

What is the maximum number of elements that can be stored in an array declared as int arr[5];?

  1. 4
  2. 5
  3. 6
  4. Depends on the compiler
Click to see the answer

Correct Answer: B.5

Explanation: The array arr can store up to 5 elements as specified by its size.

Question: 3

âš 

Which of the following statements is true about array declaration?

  1. Arrays can hold multiple data types.
  2. Array size must be a constant expression.
  3. Array elements cannot be initialized during declaration.
  4. Array indices can be negative.
Click to see the answer

Correct Answer: B. Array size must be a constant expression.

Explanation: In C, the size of an array must be a constant expression and cannot change during runtime.

Question: 4

âš 

What will be the output of the following code?

int arr[3] = {5, 10, 15};
printf('%d', arr[1]);

  1. 5
  2. 10
  3. 15
  4. Error
Click to see the answer

Correct Answer: B.10

Explanation: arr[1] accesses the second element of the array, which is 10.

Question: 5

âš 

How do you access the third element of an array named arr?

  1. arr[2]
  2. arr[3]
  3. arr(3)
  4. arr{2}
Click to see the answer

Correct Answer: A.arr[2]

Explanation: Array indices start from 0. Therefore, the third element is accessed using index 2.

Question: 6

âš 

Which of the following declarations correctly initializes an array?

  1. int arr[] = {1, 2, 3, 4};
  2. int arr[4];
  3. int arr[4] = 1, 2, 3, 4;
  4. int arr[4] = {1, 2, 3, 4, 5};
Click to see the answer

Correct Answer: A.int arr[] = {1, 2, 3, 4};

Explanation: An array can be declared and initialized without specifying its size if the initializer list is provided.

Question: 7

âš 

What is the output of the following code snippet?

int arr[5] = {1, 2, 3};
printf('%d', arr[4]);

  1. 0
  2. 3
  3. Garbage value
  4. 2
Click to see the answer

Correct Answer: A.0

Explanation: The array arr is partially initialized with 1, 2, and 3. The remaining elements are automatically set to zero.

Question: 8

âš 

How do you initialize all elements of an array to zero in C?

  1. int arr[5] = {0};
  2. int arr[5] = 0;
  3. int arr[5];
  4. int arr = {0};
Click to see the answer

Correct Answer: A.int arr[5] = {0};

Explanation: Initializing an array with {0} sets all elements to zero. The remaining elements are automatically set to zero if not specified.

Question: 9

âš 

What is the default value of uninitialized elements in an array of integers in C?

  1. 0
  2. NULL
  3. Garbage value
  4. 1
Click to see the answer

Correct Answer: C.Garbage value

Explanation: In C, if an array is declared but not explicitly initialized, its elements will contain garbage values.

Question: 10

âš 

Which of the following correctly defines a one-dimensional array in C?

  1. int arr[10];
  2. int array;
  3. int arr{10};
  4. array[10];
Click to see the answer

Correct Answer: A.int arr[10];

Explanation: In C, a one-dimensional array is defined using the syntax type name[size];. int arr[10]; correctly defines an array of 10 integers.