0% found this document useful (0 votes)
2 views4 pages

C Programming MCQs Variables to Arrays

This document contains multiple-choice questions (MCQs) focused on C programming concepts, specifically variables and arrays. It includes questions about variable declarations, array indexing, output of code snippets, and the use of format specifiers. Each question is followed by four answer options, testing the reader's understanding of C programming fundamentals.

Uploaded by

rohanbisaria58
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)
2 views4 pages

C Programming MCQs Variables to Arrays

This document contains multiple-choice questions (MCQs) focused on C programming concepts, specifically variables and arrays. It includes questions about variable declarations, array indexing, output of code snippets, and the use of format specifiers. Each question is followed by four answer options, testing the reader's understanding of C programming fundamentals.

Uploaded by

rohanbisaria58
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/ 4

C Programming MCQs: Variables to Arrays

1. What will be the output of the following code?

int a = 5;

printf("%d", a++);

A. 5

B. 6

C. Compiler Error

D. Undefined

2. Which of the following is a correct variable declaration in C?

A. int 1value;

B. float rate;

C. char name[] = 'John';

D. double = amount;

3. What is the output of this code?

int a = 3, b = 4;

printf("%d", a + b * 2);

A. 14

B. 11

C. 10

D. 7

4. Which format specifier is used to print a float value?

A. %c

B. %d

C. %f

D. %lf

Page 1
C Programming MCQs: Variables to Arrays

5. Which keyword is used to declare a constant variable in C?

A. final

B. constant

C. const

D. define

6. Which of the following array declarations is correct in C?

A. int arr(5);

B. int arr[] = {1, 2, 3};

C. int arr[] = new int[5];

D. array int arr[5];

7. What is the index of the first element in an array in C?

A. -1

B. 0

C. 1

D. Depends on compiler

8. What will be the output?

int arr[3] = {10, 20};

printf("%d", arr[2]);

A. 0

B. Garbage value

C. 10

D. Compile-time error

9. What will this code print?

int arr[5] = {1, 2, 3, 4, 5};

Page 2
C Programming MCQs: Variables to Arrays

printf("%d", *(arr + 2));

A. 2

B. 3

C. 4

D. Compilation error

10. How many elements are there in int arr[10];?

A. 9

B. 10

C. 11

D. Cannot be determined

11. Which is true about arrays in C?

A. Size must be defined at runtime

B. Elements can be different data types

C. Index starts at 1

D. All elements are of the same data type

12. What does the following code do?

int arr[3] = {1};

A. Initializes all to 1

B. Only arr[0] = 1, others = 0

C. Error

D. Garbage values

13. Which statement is true about C variables?

A. Variable names can start with a number

B. Variable names can use special characters

Page 3
C Programming MCQs: Variables to Arrays

C. Variables must be declared before use

D. Variables don't need a data type

14. What is the output of the following code?

int x = 10;

int x = 20;

printf("%d", x);

A. 10

B. 20

C. Error

D. Undefined

15. What happens if you try to access arr[10] in an array declared as int arr[5];?

A. Returns 0

B. Returns garbage

C. Runtime error (undefined behavior)

D. Compile error

Page 4

You might also like