C Language Basic To Moderate MCQs :

  1. Which function is used to print text in C?
    A) print() B) echo() C) printf() D) println()
    Answer: C

  2. Which header file is needed for printf() and scanf()?
    A) stdlib.h B) stdio.h C) conio.h D) string.h
    Answer: B

  3. C language was developed by:
    A) Dennis Ritchie B) James Gosling C) Bjarne Stroustrup D) Guido van Rossum
    Answer: A

  4. What is the correct extension for a C program file?
    A) .cpp B) .class C) .c D) .java
    Answer: C

  5. Which symbol is used for a single-line comment in C?
    A) /* B) */ C) // D) #
    Answer: C

  6. What is the default return type of a C function if not specified?
    A) int B) float C) void D) char
    Answer: A

  7. Which of the following is a valid variable name in C?
    A) 1data B) data_1 C) @data D) data-1
    Answer: B

  8. Which keyword is used to return a value from a function?
    A) get B) return C) give D) break
    Answer: B

  9. Which of the following is not a data type in C?
    A) int B) float C) real D) char
    Answer: C

  10. Which of the following symbols is used to end a statement in C?
    A) , B) : C) ; D) .
    Answer: C

  11. Which function is used to take input from the user?
    A) input() B) get() C) scanf() D) cin
    Answer: C

  12. What is the size of an int in most 32-bit compilers?
    A) 2 bytes B) 4 bytes C) 8 bytes D) 1 byte
    Answer: B

  13. Which keyword is used to define a constant in C?
    A) constant B) define C) const D) final
    Answer: C

  14. What will printf("%d", 5 + 3); print?
    A) 8 B) 5 + 3 C) Error D) None
    Answer: A

  15. The starting point of execution in a C program is:
    A) start() B) init() C) main() D) execute()
    Answer: C

  16. Which of the following is a logical operator?
    A) && B) ++ C) * D) %
    Answer: A

  17. How do you declare an integer variable in C?
    A) int num; B) integer num; C) num int; D) num = int;
    Answer: A

  18. What will printf("%c", 'A' + 1); print?
    A) A B) B C) C D) 65
    Answer: B

  19. What does %d represent in printf()?
    A) Integer B) Character C) Float D) String
    Answer: A

  20. Which function is used to clear the output screen in Turbo C?
    A) clear() B) clrscr() C) reset() D) clean()
    Answer: B

  1. Which of the following is not a keyword in C?
    A) auto B) main C) goto D) return
    Answer: B

  2. Which operator is used to get the remainder in division?
    A) / B) % C) * D) //
    Answer: B

  3. Which of the following correctly declares an array in C?
    A) int arr[]; B) int arr[5]; C) arr{5}; D) array arr(5);
    Answer: B

  4. What is the correct syntax to assign value 10 to a variable x?
    A) 10 = x; B) x == 10; C) x = 10; D) let x = 10;
    Answer: C

  5. The keyword break is used to:
    A) Exit a loop or switch B) Skip one iteration C) End a function D) Pause execution
    Answer: A

  6. What is the output of: printf("%d", 2*3 + 4);
    A) 10 B) 14 C) 12 D) 8
    Answer: A

  7. Which function is used to find the length of a string in C?
    A) size() B) strlen() C) count() D) length()
    Answer: B

  8. Which library must be included to use strlen()?
    A) string.h B) stdlib.h C) stdio.h D) conio.h
    Answer: A

  9. What is the output of: printf("%d", 5/2);
    A) 2.5 B) 2 C) 2.0 D) 3
    Answer: B

  10. Which operator is used for “AND” in C?
    A) & B) && C) and D) ||
    Answer: B

  11. What will printf("%f", 10/4); print?
    A) 2.5 B) 2.0 C) 2.000000 D) 2
    Answer: D

  12. Which of the following converts string to integer?
    A) atoi() B) itoa() C) stoi() D) toint()
    Answer: A

  13. The if statement is used for:
    A) Repetition B) Decision making C) Input D) Output
    Answer: B

  14. Which loop executes at least once even if the condition is false?
    A) for B) while C) do…while D) none
    Answer: C

  15. Which keyword is used to define a function in C?
    A) func B) define C) void/int D) function
    Answer: C

  16. What is the output of: printf("%d", 5 == 5);
    A) 1 B) 0 C) Error D) 5
    Answer: A

  17. Which format specifier is used for float values?
    A) %d B) %f C) %lf D) %c
    Answer: B

  18. What will printf("%c", 'a' - 32); print?
    A) a B) A C) b D) Error
    Answer: B

  19. Which keyword is used to include header files in C?
    A) import B) include C) using D) require
    Answer: B

  20. The statement #include <stdio.h> is a:
    A) Preprocessor directive B) Compiler command C) Function D) Loop
    Answer: A

  21. Which of these is not a looping statement?
    A) for B) if C) while D) do…while
    Answer: B

  22. The correct way to declare a pointer is:
    A) int p; B) int p; C) pointer p; D) *int p;
    Answer: A

  23. Which of these is not a valid operator?
    A) ++ B) – C) ** D) %
    Answer: C

  24. What does \n represent in a string?
    A) Null B) Newline C) Tab D) Space
    Answer: B

  25. Which function is used to read a string from the user?
    A) input() B) scanf() C) gets() D) read()
    Answer: C

  26. What is the correct syntax of a for loop?
    A) for(i=0;i<10;i++) B) for i<10 C) loop(i=0;10) D) repeat(10)
    Answer: A

  27. What is the output of printf("%d", sizeof(char));?
    A) 2 B) 4 C) 1 D) 8
    Answer: C

  28. The operator used to access structure members is:
    A) * B) . C) -> D) &
    Answer: B

  29. Which keyword is used to stop a loop?
    A) stop B) end C) break D) halt
    Answer: C

  30. What is the range of an 8-bit unsigned integer?
    A) 0 to 127 B) 0 to 255 C) -128 to 127 D) -255 to 255
    Answer: B

  31. Which operator is used to assign a value?
    A) == B) := C) = D) =>
    Answer: C

  32. What is the output of printf("%d", 3>2);?
    A) 3 B) 2 C) 1 D) 0
    Answer: C

  33. Which keyword is used to continue to the next iteration?
    A) break B) next C) continue D) skip
    Answer: C

  34. Which operator is used to perform multiplication?
    A) x B) * C) mul D) #
    Answer: B

  35. The else part of an if statement executes when:
    A) Condition is true B) Condition is false C) Always D) Never
    Answer: B

  36. Which function is used to allocate memory dynamically?
    A) malloc() B) alloc() C) memory() D) new()
    Answer: A

  37. Which function is used to release allocated memory?
    A) delete() B) free() C) remove() D) release()
    Answer: B

  38. What does EOF stand for?
    A) End Of File B) End Of Function C) Exit On Fail D) End Of Format
    Answer: A

  39. The keyword static means:
    A) Constant value B) Value preserved between calls C) External linkage D) Dynamic memory
    Answer: B

  40. Which operator is used to get the address of a variable?
    A) * B) & C) @ D) #
    Answer: B

  1. Which of these is a valid C identifier?
    A) int B) float C) my_var D) return
    Answer: C

  2. What does sizeof() operator do?
    A) Returns the type name B) Returns the variable value C) Returns the memory size D) Returns the address
    Answer: C

  3. Which of these is a valid way to declare a character variable?
    A) char ch; B) character ch; C) string ch; D) char = ch;
    Answer: A

  4. What will printf("%d", 10 != 5); print?
    A) 0 B) 1 C) 10 D) Error
    Answer: B

  5. What is the ASCII value of ‘A’?
    A) 64 B) 65 C) 66 D) 67
    Answer: B

  6. What will be the output of printf("%d", 5%2);?
    A) 1 B) 2 C) 0 D) 5
    Answer: A

  7. Which of these is not a looping construct?
    A) while B) do C) for D) switch
    Answer: D

  8. Which symbol is used to start a preprocessor directive?
    A) $ B) & C) # D) @
    Answer: C

  9. Which of the following is a conditional operator?
    A) ++ B) ?: C) && D) ||
    Answer: B

  10. What will printf("%d", 5>3 && 3>2); print?
    A) 0 B) 1 C) 2 D) Error
    Answer: B

  11. What is the output of printf("%d", 10/3);?
    A) 3.333 B) 3 C) 4 D) 10
    Answer: B

  12. What is the correct syntax of an if statement?
    A) if(condition) B) if condition C) if: condition D) if{condition}
    Answer: A

  13. Which of the following is not a storage class in C?
    A) auto B) static C) register D) local
    Answer: D

  14. Which format specifier is used for double values?
    A) %f B) %lf C) %d D) %c
    Answer: B

  15. Which keyword is used to declare a global variable?
    A) global B) extern C) static D) register
    Answer: B

  16. What does return 0; in main() signify?
    A) Successful execution B) Error occurred C) Infinite loop D) Function call
    Answer: A

  17. Which keyword is used to define constants in C?
    A) define B) constant C) fixed D) const
    Answer: D

  18. What is the correct syntax to read an integer using scanf()?
    A) scanf(“%int”, &a); B) scanf(“%d”, a); C) scanf(“%d”, &a); D) scanf(“%c”, &a);
    Answer: C

  19. What is the default value of an uninitialized local variable in C?
    A) 0 B) Null C) Undefined/Garbage D) Empty
    Answer: C

  20. Which of the following correctly increments x by 1?
    A) x = x + 1; B) x++; C) ++x; D) All of the above
    Answer: D

  21. Which function is used to convert uppercase to lowercase?
    A) tolower() B) lower() C) downcase() D) strlow()
    Answer: A

  22. Which function is used to compare two strings?
    A) strcmp() B) compare() C) strmatch() D) equal()
    Answer: A

  23. Which of the following is not a bitwise operator?
    A) & B) | C) && D) ^
    Answer: C

  24. Which symbol is used to dereference a pointer?
    A) * B) & C) @ D) %
    Answer: A

  25. What is the output of:

 
int a = 10; printf("%d", ++a);

A) 9 B) 10 C) 11 D) Error
Answer: C

  1. What will printf("%d", a--); do?
    A) Decrease a before printing B) Print and then decrease a C) Increase a D) Error
    Answer: B

  2. Which function is used to copy strings?
    A) strcpy() B) copystr() C) strcopy() D) memcpy()
    Answer: A

  3. How many bytes does char occupy?
    A) 1 B) 2 C) 4 D) 8
    Answer: A

  4. Which keyword is used to jump to a labeled statement?
    A) break B) continue C) goto D) jump
    Answer: C

  5. The main() function returns which data type by default?
    A) void B) int C) char D) float
    Answer: B

  6. Which header file contains mathematical functions like sqrt()?
    A) math.h B) stdio.h C) conio.h D) string.h
    Answer: A

  7. What is the correct syntax to declare an array of 5 integers?
    A) int[5] arr; B) int arr[5]; C) arr int[5]; D) array arr[5];
    Answer: B

  8. Which function terminates a program immediately?
    A) stop() B) end() C) exit() D) terminate()
    Answer: C

  9. Which operator is used to test equality?
    A) = B) == C) := D) equals
    Answer: B

  10. Which of the following is a relational operator?
    A) == B) ++ C) && D) %
    Answer: A

  11. Which loop checks the condition before execution?
    A) do…while B) for C) while D) Both B and C
    Answer: D

  12. Which statement is used to end the program in C?
    A) exit() B) stop() C) quit() D) break()
    Answer: A

  13. What is the size of float in C (typically)?
    A) 2 bytes B) 4 bytes C) 8 bytes D) 16 bytes
    Answer: B

  14. What is the use of #define?
    A) To define a function B) To create a macro/constant C) To declare a variable D) To start main
    Answer: B

  15. What does %s represent in printf()?
    A) String B) Character C) Integer D) Float
    Answer: A

  1. Which of these is not a valid C data type?
    A) int B) float C) bool D) double
    Answer: C

  2. Which keyword is used to include libraries in C?
    A) include B) #include C) import D) add
    Answer: B

  3. What is the use of the continue statement?
    A) Exit loop B) Skip to next iteration C) Stop program D) Jump to main
    Answer: B

  4. Which of the following denotes a newline in C?
    A) \r B) \t C) \n D) \
    Answer: C

  5. Which function is used to display formatted output?
    A) output() B) display() C) printf() D) cout
    Answer: C

  6. The main() function should always return:
    A) float B) char C) int D) void
    Answer: C

  7. What is the output of printf("%d", 3*2+4/2);?
    A) 8 B) 10 C) 7 D) 6
    Answer: A

  8. Which symbol is used for OR operation in C?
    A) || B) | C) + D) or
    Answer: A

  9. What is the correct way to define a constant in C?
    A) const int a=10; B) define a 10; C) int const=10; D) fixed a=10;
    Answer: A

  10. What will printf("%d", sizeof(int)); print on most 32-bit systems?
    A) 2 B) 4 C) 8 D) 16
    Answer: B

  11. Which function is used to read a character from keyboard?
    A) getch() B) getchar() C) read() D) get()
    Answer: B

  12. What is the output of 'A' + 1?
    A) B B) 66 C) Error D) A
    Answer: B

  13. Which function is used to copy memory blocks?
    A) memcpy() B) strcpy() C) copy() D) blockcopy()
    Answer: A

  14. Which operator has the highest precedence?
    A) + B) * C) () D) =
    Answer: C

  15. Which of the following is not a valid escape sequence?
    A) \n B) \t C) \s D) \
    Answer: C

  16. Which keyword is used to make a function visible to other files?
    A) static B) extern C) global D) public
    Answer: B

  17. Which format specifier is used for characters?
    A) %s B) %c C) %d D) %f
    Answer: B

  18. Which loop executes 0 or more times?
    A) while B) for C) do…while D) while and for
    Answer: D

  19. The statement int a[5]={1,2,3}; initializes remaining elements with:
    A) 1 B) 2 C) 0 D) garbage
    Answer: C

  20. Which operator is used to perform division?
    A) * B) % C) / D) //
    Answer: C

  21. Which function closes a file in C?
    A) endfile() B) close() C) fclose() D) stop()
    Answer: C

  22. What does NULL represent in C?
    A) Empty string B) 0 or no value C) False D) -1
    Answer: B

  23. Which keyword is used to define macros?
    A) define B) macro C) const D) typedef
    Answer: A

  24. Which of these operators is unary?
    A) + B) - C) ++ D) %
    Answer: C

  25. Which function is used to concatenate strings?
    A) strcat() B) stradd() C) join() D) append()
    Answer: A

  26. The expression a += b; is equivalent to:
    A) a = a + b; B) a = b + 1; C) a = b; D) None
    Answer: A

  27. Which keyword is used to declare a function prototype?
    A) extern B) prototype C) func D) declare
    Answer: A

  28. Which of these is not an arithmetic operator?
    A) + B) - C) * D) &&
    Answer: D

  29. What is the correct way to declare a 2D array?
    A) int a[2][3]; B) int[2,3] a; C) array[2][3]; D) int a{2}{3};
    Answer: A

  30. Which function returns the length of a string?
    A) strlen() B) size() C) length() D) count()
    Answer: A

  31. What is the output of printf("%d", 4>5);?
    A) 4 B) 5 C) 1 D) 0
    Answer: D

  32. Which of these cannot be a variable name?
    A) total B) _value C) 5num D) sum
    Answer: C

  33. Which keyword is used to declare an array?
    A) var B) array C) None (type name used) D) arr
    Answer: C

  34. What is the output of 'b' - 'a'?
    A) 0 B) 1 C) 2 D) Error
    Answer: B

  35. Which operator is known as the “address-of” operator?
    A) * B) & C) @ D) #
    Answer: B

  36. What is the output of printf("%d", 10<5);?
    A) 0 B) 1 C) 10 D) Error
    Answer: A

  37. Which keyword is used to declare enumeration?
    A) enum B) struct C) union D) typedef
    Answer: A

  38. What does %u represent in printf()?
    A) Unsigned integer B) Unicode C) Uppercase D) User value
    Answer: A

  39. The function feof() checks for:
    A) Start of file B) End of file C) Empty file D) Error
    Answer: B

  40. Which keyword is used for decision making?
    A) if B) loop C) repeat D) switch
    Answer: A

  41. Which of these is not a valid loop?
    A) do B) for C) repeat-until D) while
    Answer: C

  42. Which operator is used to increment by one?
    A) ++ B) – C) += D) =+
    Answer: A

  43. What is the maximum length of an identifier in C (standard)?
    A) 31 B) 32 C) 63 D) 127
    Answer: A

  44. The operator ! is known as:
    A) NOT B) AND C) OR D) XOR
    Answer: A

  45. Which function is used to open a file?
    A) fopen() B) open() C) start() D) fileopen()
    Answer: A

  46. What is the result of 5%10?
    A) 0 B) 5 C) 10 D) Error
    Answer: B

  47. Which function reads formatted input from keyboard?
    A) scanf() B) input() C) get() D) read()
    Answer: A

  48. Which format specifier prints an address?
    A) %p B) %d C) %f D) %s
    Answer: A

  49. Which function is used to generate random numbers?
    A) rand() B) random() C) getrand() D) rnd()
    Answer: A

  50. Which operator is used to combine conditions?
    A) & B) | C) && or || D) %
    Answer: C

  51. Which keyword is used to define a structure?
    A) struct B) class C) typedef D) object
    Answer: A

  52. What does break; do in a loop?
    A) Ends the loop B) Skips one iteration C) Restarts loop D) Pauses
    Answer: A

  53. Which operator is used for pointer dereferencing?
    A) * B) & C) -> D) .
    Answer: A

  54. What will printf("%d", 5>3 ? 10:20); print?
    A) 10 B) 20 C) 5 D) Error
    Answer: A

  55. Which of these is a valid string literal?
    A) ‘Hello’ B) Hello C) “Hello” D) (Hello)
    Answer: C

  56. Which function is used to find power in math.h?
    A) pow() B) power() C) exp() D) sqrt()
    Answer: A

  57. Which data type can store large decimal numbers?
    A) int B) float C) double D) char
    Answer: C

  58. What will printf("%d", !0); print?
    A) 0 B) 1 C) -1 D) Error
    Answer: B

  59. Which operator is used to access members using pointer?
    A) . B) -> C) * D) &
    Answer: B

  60. What does %x represent in printf()?
    A) Decimal B) Hexadecimal C) Octal D) Binary
    Answer: B

  61. What is the output of printf("%o", 10);?
    A) 10 B) 8 C) 12 D) Error
    Answer: C

  62. Which function is used to round a number?
    A) round() B) floor() C) ceil() D) Both B and C
    Answer: D

  63. The function fflush(stdout) is used to:
    A) Close file B) Clear output buffer C) Refresh input D) None
    Answer: B

  64. What is the return type of sizeof?
    A) int B) long C) size_t D) float
    Answer: C

  65. What will printf("%d", 5==5 && 5!=6); print?
    A) 0 B) 1 C) 5 D) Error
    Answer: B

  66. Which of these is a user-defined data type?
    A) struct B) int C) float D) char
    Answer: A

  67. Which function compares two characters?
    A) strcmp() B) memcmp() C) stricmp() D) chrcmp()
    Answer: A

  68. What is the default value of a static variable?
    A) 0 B) 1 C) Null D) Garbage
    Answer: A

  69. What is the return type of main() by default?
    A) int B) void C) float D) None
    Answer: A

  70. Which function writes data to a file?
    A) fwrite() B) fput() C) write() D) fdata()
    Answer: A

  71. Which operator combines both arithmetic and assignment?
    A) += B) == C) = D) ++
    Answer: A

  72. Which function is used to read data from a file?
    A) fread() B) read() C) fget() D) fdata()
    Answer: A

  73. Which function converts a string to float?
    A) atof() B) atoi() C) itof() D) strtof()
    Answer: A

  74. What is the result of 10 / 3.0?
    A) 3 B) 3.0 C) 3.333333 D) Error
    Answer: C

  75. What will printf("%d", 10>>1); print?
    A) 5 B) 10 C) 20 D) 2
    Answer: A

  76. Which function returns absolute value?
    A) abs() B) fabs() C) value() D) mod()
    Answer: A

  77. Which operator is used to perform bitwise XOR?
    A) ^ B) | C) & D) ~
    Answer: A

  78. What does %o represent in printf()?
    A) Octal B) Object C) Operator D) Overflow
    Answer: A

  79. Which function clears the console screen in C (Turbo)?
    A) clrscr() B) clear() C) reset() D) clean()
    Answer: A

  80. What will printf("%d", 1 && 0); print?
    A) 1 B) 0 C) True D) Error
    Answer: B

  81. Which of these is a valid comment syntax?
    A) # Comment B) /* Comment */ C) <Comment> D) $ Comment
    Answer: B

  82. What is the output of printf("%c", 65);?
    A) 65 B) A C) a D) Error
    Answer: B

  83. Which of these is a keyword in C?
    A) select B) case C) switcher D) choose
    Answer: B

  84. Which function terminates the string in C?
    A) ‘\0’ B) null C) \n D) end
    Answer: A

  85. Which operator is used to perform logical NOT?
    A) ! B) ~ C) ^ D) &
    Answer: A

  86. Which function is used to convert a character to uppercase?
    A) toupper() B) upper() C) cap() D) capitalize()
    Answer: A

  87. What is the output of printf("%d", 2<<1);?
    A) 1 B) 2 C) 4 D) 8
    Answer: C

  88. Which operator is used to perform bitwise AND?
    A) && B) & C) and D) %
    Answer: B

  89. Which function pauses the program until a key is pressed?
    A) getch() B) getchar() C) pause() D) wait()
    Answer: A

  90. Which of these functions allocates memory?
    A) malloc() B) calloc() C) realloc() D) All of these
    Answer: D

  91. Which data type can store true or false?
    A) bool B) int C) _Bool D) char
    Answer: C

  92. Which function converts integer to string?
    A) itoa() B) atoi() C) strint() D) tostr()
    Answer: A

  93. Which header file contains string functions?
    A) string.h B) stdlib.h C) stdio.h D) conio.h
    Answer: A

  94. Which function compares memory blocks?
    A) memcmp() B) strcmp() C) memcompare() D) checkmem()
    Answer: A

  95. What is the output of printf("%d", 2|4);?
    A) 2 B) 4 C) 6 D) 8
    Answer: C

  96. Which function is used to get the current file position?
    A) ftell() B) fseek() C) pos() D) tell()
    Answer: A

  97. Which keyword prevents modification of a variable?
    A) fixed B) const C) static D) final
    Answer: B

  98. Which function repositions file pointer?
    A) fseek() B) ftell() C) seek() D) setpos()
    Answer: A

  99. Which operator is used for assignment?
    A) == B) = C) := D) =>
    Answer: B

  100. Which header file contains memory management functions?
    A) stdlib.h B) string.h C) stdio.h D) conio.h
    Answer: A

 

C Language Moderate MCQs :

  1. What is the output of printf("%d", sizeof('A'));?
    A) 1 B) 2 C) 4 D) Depends on compiler
    Answer: C

  2. Which of the following is a valid pointer declaration?
    A) int ptr; B) int ptr; C) *int ptr; D) int &ptr;
    Answer: A

  3. What will printf("%s", NULL); do?
    A) Print “NULL” B) Print nothing C) Cause a segmentation fault D) Compile error
    Answer: C

  4. Which function dynamically allocates memory?
    A) malloc() B) calloc() C) realloc() D) All of the above
    Answer: D

  5. The operator -> is used with:
    A) Arrays B) Structures via pointers C) Functions D) Loops
    Answer: B

  6. Which function releases dynamically allocated memory?
    A) delete() B) free() C) remove() D) dispose()
    Answer: B

  7. What is the output of printf("%d", 5==5==5);?
    A) 0 B) 1 C) Error D) Undefined
    Answer: B

  8. What is the output of sizeof(3.14f)?
    A) 2 B) 4 C) 8 D) 16
    Answer: B

  9. Which of the following is not a storage class in C?
    A) static B) register C) auto D) global
    Answer: D

  10. What is the output of printf("%d", 10%(-3));?
    A) -1 B) 1 C) -2 D) Undefined
    Answer: B

  11. Which function reads a line from file until newline?
    A) fgets() B) fread() C) gets() D) readline()
    Answer: A

  12. Which of these statements is true about arrays in C?
    A) Index starts at 1 B) Size can change dynamically C) Index starts at 0 D) Arrays can’t store strings
    Answer: C

  13. What is the output of printf("%d", ++*p); where p points to integer 5?
    A) 5 B) 6 C) 7 D) Error
    Answer: B

  14. What is the size of an empty structure in C?
    A) 0 B) 1 C) Undefined D) Depends on compiler
    Answer: B

  15. What is the output of 'A' + 32?
    A) ‘a’ B) 97 C) ‘A’ D) Both A and B
    Answer: D

  16. Which of the following correctly initializes a pointer to a string literal?
    A) char *s = “Hello”; B) char s = “Hello”; C) char s[] = *”Hello”; D) *s = “Hello”;
    Answer: A

  17. What is the output of printf("%d", strcmp("abc","abd"));?
    A) 0 B) 1 C) -1 D) Garbage
    Answer: C

  18. Which function is used to set the position of file pointer?
    A) ftell() B) fseek() C) rewind() D) reposition()
    Answer: B

  19. The default return type of a function without type declaration is:
    A) int B) void C) float D) Undefined
    Answer: A

  20. What will int x = 5, y = x++; result in?
    A) x=6, y=6 B) x=6, y=5 C) x=5, y=6 D) Error
    Answer: B

  21. Which operator cannot be overloaded in C?
    A) + B) -> C) = D) ?:
    Answer: D

  22. The expression a == b == c is evaluated as:
    A) (a == b) == c B) a == (b == c) C) a == b == c D) Undefined
    Answer: A

  23. Which statement correctly opens a file for both reading and writing?
    A) fopen(“test.txt”, “rw”); B) fopen(“test.txt”, “r+”); C) fopen(“test.txt”, “rw+”); D) fopen(“test.txt”, “wr”);
    Answer: B

  24. Which of the following is a pointer to a function?
    A) int (*p)(); B) int *p(); C) *int p(); D) int &(p)();
    Answer: A

  25. What is the result of 5 & 3?
    A) 1 B) 5 C) 7 D) 0
    Answer: A

  26. What does the function strcpy(dest, src) do?
    A) Copies src to dest B) Appends src C) Compares both D) Returns length
    Answer: A

  27. What does the expression *(*(arr + 1) + 2) access?
    A) arr[2][1] B) arr[1][2] C) arr[1][1] D) arr[2][2]
    Answer: B

  28. What is the output of printf("%d", !5);?
    A) 5 B) 0 C) 1 D) -5
    Answer: B

  29. Which keyword is used to stop recursion?
    A) exit B) stop C) return D) break
    Answer: C

  30. What is the output of printf("%d", 2 << 2);?
    A) 4 B) 6 C) 8 D) 2
    Answer: C

  31. Which operator is used for conditional expression?
    A) if B) ?: C) switch D) &&
    Answer: B

  32. Which statement is true about static variables?
    A) They can’t retain value B) They retain value between calls C) They are global D) They are extern by default
    Answer: B

  33. What will be the output of:

 
int i=0; while(i<3) printf("%d",i++);

A) 012 B) 123 C) 0 1 2 D) Error
Answer: A

  1. What is the value of sizeof(int*) on a 64-bit system?
    A) 2 B) 4 C) 8 D) 16
    Answer: C

  2. Which function is used to allocate zero-initialized memory?
    A) malloc() B) calloc() C) realloc() D) free()
    Answer: B

  3. What will be the output of printf("%d", 4>>1);?
    A) 2 B) 4 C) 8 D) 1
    Answer: A

  4. Which library function compares two memory blocks?
    A) memcmp() B) strcmp() C) compare() D) check()
    Answer: A

  5. What is the correct declaration of an array of pointers?
    A) int a[5]; B) int a[5]; C) int (*a)[]; D) int *a();
    Answer: A

  6. What is the purpose of fflush(stdin);?
    A) Clears output buffer B) Clears input buffer C) Flushes both D) Undefined behavior
    Answer: D

  7. Which of the following statements is true?
    A) char arrays can hold multiple words
    B) Strings in C are null-terminated
    C) Strings are stored as objects
    D) String length is unlimited
    Answer: B

  8. What will printf("%p", main); print?
    A) Address of main() B) Name of function C) Garbage D) Error
    Answer: A

  9. What is the result of sizeof("Hello")?
    A) 5 B) 6 C) 7 D) 8
    Answer: B

  10. The default value of an automatic variable is:
    A) 0 B) Undefined (garbage) C) Null D) Random
    Answer: B

  11. Which function is used to move file pointer to the beginning?
    A) fseek(fp,0,SEEK_SET); B) rewind(fp); C) reset(fp); D) A or B
    Answer: D

  12. What is the output of printf("%d", sizeof(printf("C")));?
    A) 1 B) 2 C) 4 D) Compiler dependent
    Answer: D

  13. The maximum number of dimensions an array can have in C is:
    A) 2 B) 3 C) 5 D) Compiler dependent
    Answer: D

  14. Which function is used to compare two strings without case sensitivity?
    A) strcmpi() B) strcasecmp() C) stricmp() D) Both A and B
    Answer: D

  15. What is the output of the following?

 
int a=5; printf("%d", a+++a);

A) 10 B) 11 C) 9 D) Undefined
Answer: D

  1. Which header file defines the function exit()?
    A) stdio.h B) stdlib.h C) conio.h D) process.h
    Answer: B

  2. What will printf("%d", -10 % 3); print?
    A) 1 B) -1 C) 2 D) -2
    Answer: B

  1. What is the output of

 
int x = 10; printf("%d", x++ + ++x);

A) 21 B) 22 C) Undefined D) 20
Answer: C

  1. Which function is used to reposition the file pointer to the end of a file?
    A) fseek(fp, 0, SEEK_END); B) rewind(fp); C) fclose(fp); D) ftell(fp);
    Answer: A

  2. What is the output of

 
printf("%d", printf("C"));

A) C1 B) C2 C) 1C D) Depends on compiler
Answer: A

  1. The function realloc(ptr, new_size) is used to:
    A) Reallocate memory B) Free memory C) Copy memory D) Reset memory
    Answer: A

  2. Which function returns the string length excluding the null character?
    A) strlen() B) sizeof() C) strsize() D) count()
    Answer: A

  3. Which header must be included for toupper()?
    A) ctype.h B) string.h C) stdlib.h D) stdio.h
    Answer: A

  4. What will the following code print?

 
int i = 0; for (; i < 5; i++); printf("%d", i);

A) 0 B) 4 C) 5 D) Error
Answer: C

  1. In C, which statement is correct about pointers and arrays?
    A) Arrays are pointers B) Pointers and arrays are unrelated
    C) Array name is a constant pointer D) Array name is a variable
    Answer: C

  2. Which operator has the lowest precedence in C?
    A) = B) ++ C) * D) ()
    Answer: A

  3. Which header defines the function malloc()?
    A) stdlib.h B) stdio.h C) memory.h D) malloc.h
    Answer: A

  4. Which function converts an integer to string safely in C?
    A) itoa() B) sprintf() C) snprintf() D) strint()
    Answer: C

  5. What is the output of

 
int a = 5; printf("%d", a += (a *= 2) + 1);

A) 16 B) 10 C) 17 D) Undefined
Answer: A

  1. What is the effect of extern keyword?
    A) Defines a new variable B) Declares a variable defined elsewhere C) Makes variable private D) Frees variable
    Answer: B

  2. What does the statement int (*p)[5]; mean?
    A) p is a pointer to an array of 5 ints B) Array of 5 int pointers C) Array pointer D) Function pointer
    Answer: A

  3. Which format specifier displays a float in exponential form?
    A) %f B) %e C) %g D) %lf
    Answer: B

  4. What will this program output?

 
int x = 5; if (x = 0) printf("Zero"); else printf("Non-zero");

A) Zero B) Non-zero C) Error D) None
Answer: B

  1. Which of these correctly defines a structure variable?
    A) struct student s; B) structure student s; C) student struct s; D) define student s;
    Answer: A

  2. What is the result of 5 | 2?
    A) 7 B) 10 C) 2 D) 5
    Answer: A

  3. Which function reads formatted input from a file?
    A) scanf() B) fscanf() C) readf() D) inputf()
    Answer: B

  4. The pointer returned by malloc() is of type:
    A) void * B) int * C) char * D) generic *
    Answer: A

  5. What is the output of

 
int a = 10; printf("%d", a == 10 ? 100 : 200);

A) 100 B) 200 C) 10 D) Error
Answer: A

  1. Which statement is used to handle errors in file operations?
    A) ferror() B) perror() C) feof() D) All of these
    Answer: D

  2. The value of sizeof(double) on most 64-bit compilers is:
    A) 4 B) 6 C) 8 D) 10
    Answer: C

  3. Which function returns a pointer to the first occurrence of a character in a string?
    A) strchr() B) strstr() C) strrchr() D) findchar()
    Answer: A

  4. What will be the output of

 
int a=2,b=3; printf("%d", a+++b);

A) 5 B) 6 C) Syntax error D) Undefined
Answer: A

  1. Which function in <math.h> returns the remainder of division?
    A) fmod() B) mod() C) rem() D) remain()
    Answer: A

  2. Which keyword makes a variable visible only within the same source file?
    A) static B) extern C) const D) register
    Answer: A

  3. What is the output of

 
printf("%c", "Hello"[1]);

A) H B) e C) l D) o
Answer: B

  1. What will happen if you free() a NULL pointer?
    A) Segmentation fault B) Undefined behavior C) No effect D) Compiler error
    Answer: C

  2. Which function sets all bytes in a block of memory to zero?
    A) bzero() B) memset() C) clear() D) memclr()
    Answer: B

  3. What is the return type of sizeof operator?
    A) int B) unsigned int C) size_t D) long
    Answer: C

  4. What does this loop print?

 
for(int i=0; i<3; i++) for(int j=0; j<2; j++) printf("*");

A) 6 asterisks B) 3 asterisks C) 2 asterisks D) Error
Answer: A

  1. Which of the following is not valid in C?
    A) void main() B) int main(void) C) main() D) int main(int argc, char *argv[])
    Answer: A

  2. The keyword typedef is used to:
    A) Allocate memory B) Define alias for data types C) Define macros D) None
    Answer: B

  3. What is the output of

 
int x = 1; printf("%d", x << 3);

A) 8 B) 3 C) 2 D) 1
Answer: A

  1. What is the output of

 
int a=1; while(a<=3) printf("%d", a++);

A) 1 2 3 B) 123 C) 0 1 2 D) Infinite loop
Answer: B

  1. Which function compares two strings up to n characters?
    A) strncmp() B) strcomp() C) strncm() D) strmatch()
    Answer: A

  2. What is the value of expression sizeof(4.5)?
    A) 4 B) 8 C) 2 D) 10
    Answer: B

  3. Which header defines mathematical constants like M_PI?
    A) math.h B) const.h C) stdlib.h D) stdio.h
    Answer: A

  4. What will be the output of

 
char s[]="C"; printf("%d", sizeof(s));

A) 1 B) 2 C) 3 D) Undefined
Answer: B

  1. Which of these is a correct recursive factorial function prototype?
    A) int fact(int n); B) fact(int n); C) int fact(); D) int fact(int n, int r);
    Answer: A

  2. What is the value of printf("%d", strcmp("AB", "AC"));?
    A) 0 B) 1 C) -1 D) 2
    Answer: C

  3. Which pointer always contains the current function’s stack frame base?
    A) stack pointer B) frame pointer C) base pointer D) both B and C
    Answer: D

  4. What does fprintf(fp, "%s", str); do?
    A) Writes string to file B) Reads string from file C) Formats file D) None
    Answer: A

  5. What is printed by

 
int x = 2, y = 3; printf("%d", x && y || 0);

A) 0 B) 1 C) 2 D) 3
Answer: B

  1. What is the output of printf("%d", (int)3.99);?
    A) 3 B) 4 C) 3.99 D) Error
    Answer: A

  2. What will printf("%c", *"CProgramming"); print?
    A) C B) P C) Error D) Nothing
    Answer: A

  3. Which function returns current system time?
    A) time() B) gettime() C) systemtime() D) clock()
    Answer: A

  4. Which preprocessor directive is used to avoid multiple inclusions of header files?
    A) #ifndef / #define B) #protect C) #onceonly D) #safe
    Answer: A

  5. Which function converts a string to long int?
    A) atol() B) atoi() C) strtol() D) Both A and C
    Answer: D

  1. What is the output of

 
int a = 5;
printf("%d", a++ + ++a);

A) 11 B) 12 C) Undefined D) 10
Answer: C

  1. What does the continue statement do in a loop?
    A) Exits the loop B) Skips remaining statements and starts next iteration C) Restarts loop D) Ends program
    Answer: B

  2. Which function is used to open a file in C?
    A) openfile() B) fopen() C) fileopen() D) start()
    Answer: B

  3. What will be the output of

 
char str[] = "C";
printf("%d", sizeof(str));

A) 1 B) 2 C) 3 D) 4
Answer: B

  1. Which storage class makes a variable retain its value between function calls?
    A) auto B) register C) static D) extern
    Answer: C

  2. Which operator is used to access structure members through a pointer?
    A) . B) -> C) & D) *
    Answer: B

  3. What is the output of

 
int x=2, y=3;
printf("%d", (x>y)?x:y);

A) 2 B) 3 C) 0 D) Error
Answer: B

  1. Which keyword prevents modification of a variable?
    A) constant B) static C) const D) immutable
    Answer: C

  2. Which function is used to copy n characters from one string to another?
    A) strncpy() B) strcpy() C) strcopy() D) memcpy()
    Answer: A

  3. Which data type has the highest precision?
    A) float B) double C) long double D) int
    Answer: C

  4. The statement int (*fun)(int, int); means:
    A) fun is a pointer to function B) fun is a function C) fun is an array D) fun is a macro
    Answer: A

  5. What is the output of

 
printf("%d", 10/4);

A) 2.5 B) 2 C) 3 D) Error
Answer: B

  1. The correct way to dynamically allocate an array of 5 integers:
    A) int p = malloc(5sizeof(int)); B) int p = malloc(5); C) int p[5]; D) malloc(5,int);
    Answer: A

  2. Which function is used to get the current position of file pointer?
    A) fseek() B) ftell() C) rewind() D) feof()
    Answer: B

  3. Which of these is not a valid identifier?
    A) _abc B) 1num C) value D) printf1
    Answer: B

  4. What is the size of int on most 32-bit compilers?
    A) 2 B) 4 C) 8 D) 6
    Answer: B

  5. Which function terminates a program immediately?
    A) end() B) stop() C) exit() D) terminate()
    Answer: C

  6. Which operator is used to allocate memory dynamically?
    A) new B) malloc() C) alloc() D) getmem()
    Answer: B

  7. Which function is used to concatenate two strings?
    A) strcat() B) append() C) join() D) stradd()
    Answer: A

  8. What is the output of

 
int a=5;
printf("%d", a==5);

A) 5 B) 1 C) 0 D) Error
Answer: B

  1. Which keyword is used to include header files in C?
    A) include B) #include C) import D) use
    Answer: B

  2. Which function is used to find a substring in another string?
    A) strstr() B) strchr() C) strcmp() D) strcpy()
    Answer: A

  3. Which operator checks both sides before executing second condition?
    A) & B) && C) | D) ||
    Answer: B

  4. What is the output of

 
int x=5;
printf("%d", ++x + x++);

A) 11 B) 12 C) Undefined D) 10
Answer: C

  1. What does %u represent in printf()?
    A) unsigned int B) universal value C) unique char D) uninitialized variable
    Answer: A

  2. Which header file contains memcpy()?
    A) stdlib.h B) string.h C) stdio.h D) memory.h
    Answer: B

  3. Which operator is used to perform bitwise AND?
    A) & B) && C) | D) ^
    Answer: A

  4. Which keyword is used to define a constant value?
    A) const B) define C) #define D) fixed
    Answer: C

  5. What will this print?

 
char c='A';
printf("%d", c);

A) A B) 65 C) ‘A’ D) Error
Answer: B

  1. Which data type can hold both integer and decimal values?
    A) int B) float C) char D) void
    Answer: B

  2. What does the expression (a = b) do?
    A) Compares a and b B) Assigns b to a C) Adds them D) Returns 0
    Answer: B

  3. Which function is used to read one character from file?
    A) getc() B) fgets() C) getchar() D) scanf()
    Answer: A

  4. Which library must be included for sqrt()?
    A) math.h B) stdlib.h C) string.h D) stdio.h
    Answer: A

  5. Which escape sequence represents a new line?
    A) \t B) \r C) \n D) \
    Answer: C

  6. What is the output of

 
int i=5;
printf("%d", i>>1);

A) 2 B) 2.5 C) 10 D) 1
Answer: A

  1. Which of these is not a valid loop in C?
    A) for B) do-while C) repeat-until D) while
    Answer: C

  2. What is the return type of main() in standard C?
    A) void B) int C) char D) none
    Answer: B

  3. Which function is used to clear output buffer?
    A) fflush(stdout); B) clear(); C) reset(); D) flush();
    Answer: A

  4. What is the output of

 
int a=3;
printf("%d", a>2?++a:--a);

A) 2 B) 3 C) 4 D) 5
Answer: C

  1. What is the meaning of NULL in C?
    A) Empty string B) Zero pointer C) 0 value D) None
    Answer: B

  2. What is the default return type of a C function if not specified?
    A) int B) void C) float D) char
    Answer: A

  3. What is the output of

 
int a=10;
printf("%d", a+=a*=2);

A) 30 B) 40 C) 10 D) Undefined
Answer: A

  1. Which of these converts string to integer?
    A) atoi() B) atof() C) atol() D) strint()
    Answer: A

  2. Which function is used to print error messages?
    A) perror() B) ferror() C) print_err() D) stderr()
    Answer: A

  3. What does the sizeof operator return?
    A) Memory size in bits B) Memory size in bytes C) Value count D) None
    Answer: B

  4. Which is the correct syntax to declare pointer to pointer?
    A) int **p; B) int p; C) *int *p; D) pointer int p;
    Answer: A

  5. What is the output of

 
char *p="C";
printf("%c", *p);

A) C B) *p C) p D) Error
Answer: A

  1. Which keyword defines a macro?
    A) const B) #define C) define D) static
    Answer: B

  2. Which function is used to compare two strings?
    A) strcmp() B) strcomp() C) strmatch() D) strdiff()
    Answer: A

  3. What will be printed by

 
int i=0;
while(i++<3) printf("%d",i);

A) 1 2 3 B) 1 2 3 4 C) 123 D) 0123
Answer: C

Thank you so much!!

You cannot copy content of this page

Scroll to Top