Learn C MCQs

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

Which of the following is used to allocate memory dynamically?

1) malloc()

2) calloc()

3) Both 1 and 2

4) free()

Answer : Option 3

What is the output of printf("%d", 3 && 5);?

1) 0

2) 1

3) 3

4) 5

Answer : Option 2

Which of the following is the correct way to define a function that returns a pointer?

1) int* func();

2) int func*();

3) pointer func();

4) None of the above

Answer : Option 1

What is the output of printf("%d", 10 / 2 - 3);?

1) 2

2) 5

3) 1

4) 4

Answer : Option 1

Which of the following is used to find the length of a string?

1) strlen()

2) size()

3) count()

4) None of the above

Answer : Option 1

What is the output of printf("%d", 6 && 8);?

1) 0

2) 1

3) 6

4) 8

Answer : Option 2

Which of the following can be used to return multiple values from a function?

1) Using structures

2) Using pointers

3) Both 1 and 2

4) None of the above

Answer : Option 3