C Programming MCQ Test
81 C Programming multiple-choice questions with answers, from the PGDCA syllabus. Instant score, full answer review, free and no signup.
Each attempt picks 25 questions at random from the 81 in this topic.
Score 50% or more? Get a certificate at 40% off
Finish any PGDCA test on this site with a score of 50% or above and you can claim a course certificate from Alien Institute of Computer at a 40% discount. Your score appears on the result screen with a WhatsApp button that carries it across for you.
Ask about the certificateAll 81 C Programming questions with answers
1. Who developed the C programming language?
- A. James Gosling
- B. Dennis Ritchie
- C. Bjarne Stroustrup
- D. Guido van Rossum
Answer: Dennis Ritchie
2. At which laboratory was C originally developed?
- A. IBM Research
- B. Bell Laboratories
- C. Xerox PARC
- D. MIT Media Lab
Answer: Bell Laboratories
3. Which of these is the correct extension for a C source file?
- A. .cpp
- B. .c
- C. .cs
- D. .class
Answer: .c
4. Execution of a C program always begins with which function?
- A. start()
- B. begin()
- C. main()
- D. init()
Answer: main()
5. Which symbol is used to end most statements in C?
- A. Colon (:)
- B. Semicolon (;)
- C. Full stop (.)
- D. Comma (,)
Answer: Semicolon (;)
6. What is the size of an int on a typical 32-bit compiler?
- A. 1 byte
- B. 2 bytes
- C. 4 bytes
- D. 8 bytes
Answer: 4 bytes
7. Which header file must be included to use printf() and scanf()?
- A. conio.h
- B. stdio.h
- C. stdlib.h
- D. string.h
Answer: stdio.h
8. Which format specifier is used to print an integer?
- A. %c
- B. %d
- C. %f
- D. %s
Answer: %d
9. Which format specifier is used to print a float value?
- A. %d
- B. %f
- C. %c
- D. %l
Answer: %f
10. Which format specifier is used to read a string with scanf()?
- A. %c
- B. %d
- C. %s
- D. %p
Answer: %s
11. What is the value of an uninitialised local variable in C?
- A. Always zero
- B. Always one
- C. Undefined (garbage)
- D. NULL
Answer: Undefined (garbage)
12. Which keyword is used to define a constant value in C?
- A. final
- B. const
- C. static
- D. fixed
Answer: const
13. Which of these is NOT a valid C keyword?
- A. auto
- B. register
- C. function
- D. volatile
Answer: function
14. Which operator is used to get the address of a variable?
- A. *
- B. &
- C. #
- D. @
Answer: &
15. Which operator is used to access the value stored at an address?
- A. &
- B. *
- C. ->
- D. .
Answer: *
16. What does the modulus operator % return?
- A. The quotient
- B. The remainder
- C. The percentage
- D. The power
Answer: The remainder
17. What is the result of 7 / 2 when both operands are integers in C?
- A. 3.5
- B. 3
- C. 4
- D. 0
Answer: 3
18. Which operator has the highest precedence in C?
- A. +
- B. *
- C. ()
- D. =
Answer: ()
19. What does the ++ operator do?
- A. Adds two variables
- B. Increases the value by one
- C. Doubles the value
- D. Squares the value
Answer: Increases the value by one
20. In i++ (post-increment), when is the value of i increased?
- A. Before the expression is evaluated
- B. After the expression is evaluated
- C. It is never increased
- D. Only inside loops
Answer: After the expression is evaluated
21. Which of these is a logical operator in C?
- A. &&
- B. &
- C. %
- D. <<
Answer: &&
22. Which operator is the equality comparison in C?
- A. =
- B. ==
- C. ===
- D. :=
Answer: ==
23. What is the ternary operator in C?
- A. ? :
- B. && ||
- C. ++ --
- D. << >>
Answer: ? :
24. Which loop in C is guaranteed to execute at least once?
- A. for loop
- B. while loop
- C. do-while loop
- D. nested loop
Answer: do-while loop
25. Which statement immediately exits a loop in C?
- A. continue
- B. break
- C. return
- D. exit
Answer: break
26. Which statement skips the rest of the current loop iteration?
- A. break
- B. continue
- C. goto
- D. skip
Answer: continue
27. How many times does the loop 'for(i=0; i<5; i++)' run?
- A. 4 times
- B. 5 times
- C. 6 times
- D. Infinite
Answer: 5 times
28. Which control statement is used to choose between many fixed values?
- A. if-else
- B. switch
- C. while
- D. for
Answer: switch
29. In a switch statement, what happens if break is omitted from a case?
- A. The program crashes
- B. Execution falls through to the next case
- C. The switch exits
- D. The case is skipped
Answer: Execution falls through to the next case
30. What can a switch statement in C NOT switch on?
- A. int
- B. char
- C. float
- D. enum
Answer: float
31. What is the index of the first element of an array in C?
- A. -1
- B. 0
- C. 1
- D. Depends on the compiler
Answer: 0
32. How is an array of 10 integers declared in C?
- A. int arr(10);
- B. int arr[10];
- C. array int arr[10];
- D. int arr{10};
Answer: int arr[10];
33. What does the name of an array represent in C?
- A. The first element's value
- B. The address of the first element
- C. The array size
- D. The last element
Answer: The address of the first element
34. Does C check array bounds at run time?
- A. Yes, always
- B. No, it does not
- C. Only for char arrays
- D. Only in debug mode
Answer: No, it does not
35. Which character terminates a string in C?
- A. \n
- B. \0
- C. \t
- D. EOF
Answer: \0
36. Which function returns the length of a string in C?
- A. length()
- B. strlen()
- C. size()
- D. count()
Answer: strlen()
37. Which function copies one string into another?
- A. strcat()
- B. strcpy()
- C. strcmp()
- D. strchr()
Answer: strcpy()
38. Which function joins two strings together?
- A. strcpy()
- B. strcat()
- C. strlen()
- D. strrev()
Answer: strcat()
39. What does strcmp() return when two strings are equal?
- A. 1
- B. 0
- C. -1
- D. NULL
Answer: 0
40. How much memory does char str[10] reserve?
- A. 9 bytes
- B. 10 bytes
- C. 11 bytes
- D. 20 bytes
Answer: 10 bytes
41. What is a pointer in C?
- A. A variable that stores a memory address
- B. A special kind of loop
- C. A type of array
- D. A comment marker
Answer: A variable that stores a memory address
42. How is an integer pointer declared?
- A. int p*;
- B. int *p;
- C. pointer int p;
- D. int &p;
Answer: int *p;
43. What value does a NULL pointer hold?
- A. A random address
- B. Address zero / no valid address
- C. The first array element
- D. -1
Answer: Address zero / no valid address
44. Which function allocates memory dynamically at run time?
- A. alloc()
- B. malloc()
- C. new()
- D. create()
Answer: malloc()
45. Which function releases dynamically allocated memory?
- A. delete()
- B. free()
- C. remove()
- D. clear()
Answer: free()
46. How does calloc() differ from malloc()?
- A. It is faster
- B. It initialises the memory to zero
- C. It cannot fail
- D. It works only for strings
Answer: It initialises the memory to zero
47. Which function resizes a previously allocated memory block?
- A. resize()
- B. realloc()
- C. remalloc()
- D. expand()
Answer: realloc()
48. What does malloc() return if the allocation fails?
- A. 0
- B. NULL
- C. -1
- D. A garbage address
Answer: NULL
49. In C, how are arguments passed to a function by default?
- A. By reference
- B. By value
- C. By pointer
- D. By name
Answer: By value
50. What is a function that calls itself called?
- A. Nested function
- B. Recursive function
- C. Inline function
- D. Static function
Answer: Recursive function
51. What must every recursive function have to avoid infinite recursion?
- A. A loop
- B. A base condition
- C. A global variable
- D. A pointer
Answer: A base condition
52. What does the return type void mean for a function?
- A. It returns zero
- B. It returns nothing
- C. It returns a pointer
- D. It returns an error
Answer: It returns nothing
53. What is a structure in C?
- A. A collection of variables of different data types under one name
- B. A type of loop
- C. A built-in function
- D. A pointer array
Answer: A collection of variables of different data types under one name
54. Which keyword defines a structure in C?
- A. class
- B. struct
- C. record
- D. type
Answer: struct
55. Which operator accesses a structure member through a pointer?
- A. .
- B. ->
- C. ::
- D. &
Answer: ->
56. How does a union differ from a structure?
- A. A union can hold only integers
- B. All union members share the same memory location
- C. A union cannot be nested
- D. A union has no members
Answer: All union members share the same memory location
57. Which storage class keeps a local variable's value between function calls?
- A. auto
- B. static
- C. register
- D. extern
Answer: static
58. Which storage class suggests storing a variable in a CPU register?
- A. static
- B. register
- C. extern
- D. volatile
Answer: register
59. Which storage class declares a variable defined in another file?
- A. static
- B. extern
- C. auto
- D. const
Answer: extern
60. Which mode opens a file for reading in C?
- A. "w"
- B. "r"
- C. "a"
- D. "x"
Answer: "r"
61. Which file mode adds data to the end of an existing file?
- A. "r"
- B. "w"
- C. "a"
- D. "r+"
Answer: "a"
62. What happens when a file is opened in "w" mode and already exists?
- A. It is appended to
- B. Its contents are erased
- C. An error occurs
- D. It is opened read-only
Answer: Its contents are erased
63. Which function closes an open file in C?
- A. close()
- B. fclose()
- C. endfile()
- D. fend()
Answer: fclose()
64. What does fopen() return if the file cannot be opened?
- A. 0
- B. NULL
- C. -1
- D. EOF
Answer: NULL
65. Which preprocessor directive includes a header file?
- A. #define
- B. #include
- C. #import
- D. #header
Answer: #include
66. Which preprocessor directive creates a macro?
- A. #include
- B. #define
- C. #macro
- D. #const
Answer: #define
67. When does the preprocessor run?
- A. After compilation
- B. Before compilation
- C. During linking
- D. At run time
Answer: Before compilation
68. Which symbol begins a single-line comment in C99 and later?
- A. #
- B. //
- C. --
- D. **
Answer: //
69. How is a multi-line comment written in C?
- A. // ... //
- B. /* ... */
- C. <!-- ... -->
- D. ''' ... '''
Answer: /* ... */
70. What is the output of printf("%d", 10 > 5); in C?
- A. 0
- B. 1
- C. 10
- D. 5
Answer: 1
71. Which of these correctly represents a two-dimensional array?
- A. int a[3,4];
- B. int a[3][4];
- C. int a(3)(4);
- D. int a{3}{4};
Answer: int a[3][4];
72. What is the value of sizeof(char) in C?
- A. 1
- B. 2
- C. 4
- D. 8
Answer: 1
73. Which of these is NOT a valid variable name in C?
- A. total_marks
- B. _count
- C. 2ndValue
- D. value2
Answer: 2ndValue
74. Is C a case-sensitive language?
- A. Yes
- B. No
- C. Only for keywords
- D. Only for functions
Answer: Yes
75. What does the exit() function do?
- A. Exits the current loop
- B. Terminates the program
- C. Closes a file
- D. Returns from a function
Answer: Terminates the program
76. Which library must be included to use malloc() and free()?
- A. stdio.h
- B. stdlib.h
- C. string.h
- D. math.h
Answer: stdlib.h
77. What is the purpose of the typedef keyword?
- A. To create a new data type from scratch
- B. To give an existing type a new name
- C. To convert one type to another
- D. To delete a type
Answer: To give an existing type a new name
78. Which escape sequence moves the cursor to a new line?
- A. \t
- B. \n
- C. \r
- D. \b
Answer: \n
79. Which escape sequence inserts a horizontal tab?
- A. \n
- B. \t
- C. \v
- D. \a
Answer: \t
80. What does the getchar() function do?
- A. Prints a character
- B. Reads a single character from input
- C. Deletes a character
- D. Converts a character to uppercase
Answer: Reads a single character from input
81. What is the correct way to compare two strings in C?
- A. Using ==
- B. Using strcmp()
- C. Using equals()
- D. Using =
Answer: Using strcmp()
Frequently asked questions
How many C Programming questions are in this test?
This page has 81 C Programming MCQs with answers. Each attempt picks 25 of them at random.
Is the C Programming test free?
Yes — it is free, needs no signup, and you can retake it as many times as you like.
Can I get a certificate for this test?
Score 50% or more and you can claim a certificate from Alien Institute of Computer at 40% off. The WhatsApp button appears on your result screen.