Learn C MCQs

Prepare C MCQs (Multiple choice Questions) for exam and job interviews.

What is the size of an int data type on a 32-bit machine?

1) 2 bytes

2) 4 bytes

3) 8 bytes

4) Depends on the compiler

Answer : Option 2

What is the value of uninitialized global variables in C?

1) 0

2) Random value

3) NULL

4) Garbage value

Answer : Option 1

Which of the following functions can be used to compare two strings in C?

1) strcmp()

2) strcat()

3) strcpy()

4) strlen()

Answer : Option 1

Which loop is more suitable when the number of iterations is known beforehand?

1) while

2) for

3) do-while

4) None of the above

Answer : Option 2

What is the value returned by the `main` function in C when it runs successfully?

1) 0

2) 1

3) -1

4) None

Answer : Option 1

Which operator is used to get the value stored at the address of a pointer?

1) &

2) *

3) ->

4) .

Answer : Option 2

Which of the following is used to define a block of statements in C?

1) { }

2) [ ]

3) ( )

4) < >

Answer : Option 1

Which function is used to close a file in C?

1) close()

2) fclose()

3) end()

4) fileclose()

Answer : Option 2

Which of the following statements is correct about pointers in C?

1) Pointers can store any data type.

2) Pointers store the address of another variable.

3) Pointers can point to a function.

4) Pointers store the value of a variable.

Answer : Option 2

Which of the following is the correct syntax to initialize an array in C?

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

2) int arr = [1, 2, 3];

3) arr[3] = {1, 2, 3};

4) int arr[3] = 1, 2, 3;

Answer : Option 1