C Programming Aptitude Test - MCQ Questions With Answers

This post presents the C Programming Aptitude Test for beginners with 25 multiple-choice questions.

These MCQ questions cover fundamental aspects of C programming, making them suitable for beginners to test their understanding and grasp of basic concepts of C programming.

1. What is the standard identifier for the standard input stream in C?

a) input
b) stdout
c) stdin
d) filein

2. What is the return type of the malloc function?

a) int
b) double
c) void*
d) char*

3. Which of the following operators has the highest precedence?

a) +
b) *
c) ==
d) &&

4. How do you comment on a single line in C?

a) <!-- -->
b) //
c) /* */
d) **

5. Which data type is typically used to store characters in C?

a) int
b) double
c) char
d) float

6. What is the correct way to declare a constant in C?

a) int const value;
b) constant int value;
c) #define value
d) both a) and c)

7. What does the sizeof operator return?

a) Length of a string
b) Size of a data type
c) Number of elements in an array
d) None of the above

8. What is the default return type of a function in C if it is not specified?

a) int
b) void
c) double
d) float

9. Which header file must be included to use the printf and scanf functions?

a) <string.h>
b) <stdio.h>
c) <stdlib.h>
d) <math.h>

10. What is the purpose of the return 0; statement at the end of a main function?

a) Ends the program
b) Returns control to the operating system
c) Indicates that the program ended successfully
d) All of the above

11. How do you initialize an array in C?

a) int arr = {1, 2, 3};
b) int arr[] = {1, 2, 3};
c) int arr(1, 2, 3);
d) array arr = {1, 2, 3};

12. Which loop structure checks the terminating condition at the end of the loop body?

a) for loop
b) while loop
c) do-while loop
d) None of the above

13. What keyword is used to exit a loop in C?

a) exit
b) break
c) continue
d) return

14. What is the value of the expression 3+2*5?

a) 25
b) 13
c) 10
d) 15

15. Which header file is required to perform mathematical operations like sqrt()?

a) <string.h>
b) <stdio.h>
c) <math.h>
d) <stdlib.h>

16. What is an infinite loop?

a) A loop with no end
b) A loop that executes a limited number of times
c) A loop that crashes the program
d) A loop that returns zero

17. How are command-line arguments passed to the main function in C?

a) argc and argv[]
b) args[]
c) params[]
d) None of the above

18. What is a syntax error in C?

a) An error due to incorrect use of the programming language rules
b) An error found during the program execution
c) An error that does not stop the program from executing
d) All of the above

19. Which is not a valid variable name in C?

a) int number;
b) float rate;
c) double account-balance;
d) char grade;

20. What is a function prototype?

a) The first line of a function
b) A call to a function
c) A declaration of a function specifying the function's name, return type, and parameters
d) A type of function that returns a pointer

21. What does the following expression evaluate?

5 == 5
a) True
b) False
c) 1
d) 0

22. How do you allocate memory dynamically in C?

a) alloc()
b) malloc()
c) new
d) create()

23. What is the output when the following code is executed?

int x = 5;
int y = x++;
a) x=6, y=5
b) x=5, y=6
c) x=6, y=6
d) x=5, y=5

24. Which of the following is a correct identifier in C?

a) 2things
b) _hello
c) $dollar
d) none of the above

25. What will be the result of the following operation?

10 / 4
a) 2.5
b) 2
c) 2.0
d) None of the above