11 Sep 100 C Programming MCQ (Multiple Choice Questions) with Answers
Show Answer
Explanation
2) Which of the following is the correct extension of a C source file?
Show Answer
Explanation
3) Which operator is used to get the memory address of a variable in C?
Show Answer
Explanation
4) What is the correct syntax to output “Hello World” in C?
Show Answer
Explanation
5) Which format specifier is used to print an integer in printf()?
Show Answer
Explanation
6) What is the size of int data type in standard 32-bit C compiler?
Show Answer
Explanation
7) Which keyword is used to declare a variable whose value cannot be changed?
Show Answer
Explanation
8) What is the index of the first element in a C array?
Show Answer
Explanation
9) Which header file is required to use printf() and scanf() functions?
Show Answer
Explanation
10) What does the main() function return by default to indicate successful execution?
Show Answer
Explanation
11) Which of the following is NOT a valid C variable name?
Show Answer
Explanation
12) Which operator is used to dereference a pointer in C?
Show Answer
Explanation
13) What function is used to dynamically allocate memory in C?
Show Answer
Explanation
14) Which function is used to free dynamically allocated memory?
Show Answer
Explanation
15) What will 10 % 3 evaluate to in C?
Show Answer
Explanation
16) Which of the following is a conditional selection operator in C?
Show Answer
Explanation
condition ? value_if_true : value_if_false. The others are logical and relational operators.17) How do you write a single-line comment in modern C (C99 onwards)?
Show Answer
Explanation
18) What is the output of sizeof(char) in C?
Show Answer
Explanation
19) Which library function is used to copy one string to another?
Show Answer
Explanation
20) What is the default return type of a function in C if not specified?
Show Answer
Explanation
21) Which keyword is used to exit from a loop or switch block immediately?
Show Answer
Explanation
22) Which statement skips the remaining code in the current iteration of a loop?
Show Answer
Explanation
23) What character terminates a standard C string?
Show Answer
Explanation
24) What is a pointer that points to no valid memory location called?
Show Answer
Explanation
25) Which function is used to compare two strings in C?
Show Answer
Explanation
26) Which header file is required for functions like malloc() and free()?
Show Answer
Explanation
27) What is the format specifier for a single character in scanf()?
Show Answer
Explanation
28) Which keyword is used to create a custom type name in C?
Show Answer
Explanation
typedef unsigned int uint;. struct, enum and union define new aggregate/composite types rather than aliases.29) In a struct, how are members stored in memory?
Show Answer
Explanation
30) In a union, how are members stored in memory?
Show Answer
Explanation
31) What operator is used to access structure members using a structure pointer?
Show Answer
Explanation
ptr->name. It is shorthand for (*ptr).name. The dot operator is used with a struct variable directly.32) What is the format specifier used for printing floating-point numbers?
Show Answer
Explanation
33) Which preprocessor directive is used to define symbolic constants in C?
Show Answer
Explanation
#define PI 3.14159. #include pulls in a header, #undef removes a macro, and #pragma issues compiler-specific instructions.34) What will happen if you access an array out of its defined bounds in C?
Show Answer
Explanation
35) What is the scope of a variable declared inside a function block?
Show Answer
Explanation
36) Which function is used to read a string with spaces from standard input?
Show Answer
Explanation
37) What function is used to calculate the length of a string in C?
Show Answer
Explanation
38) Which keyword is used to pass back a value from a function?
Show Answer
Explanation
39) What is a generic pointer in C that can point to data of any type?
Show Answer
Explanation
40) What is the output of printf(“%d”, 5 / 2); in integer arithmetic?
Show Answer
Explanation
41) Which storage class retains a local variable’s value between function calls?
Show Answer
Explanation
42) What is the default storage class for local variables in C?
Show Answer
Explanation
43) Which keyword is used to declare a variable defined in another file?
Show Answer
Explanation
44) What does the operator ++i do compared to i++?
Show Answer
Explanation
45) Which of the following is a bitwise AND operator in C?
Show Answer
Explanation
46) Which of the following is a logical OR operator in C?
Show Answer
Explanation
47) What will malloc() return if memory allocation fails?
Show Answer
Explanation
48) What function reallocates memory to a new size in C?
Show Answer
Explanation
49) What is the primary difference between malloc() and calloc()?
Show Answer
Explanation
50) Which mode is used in fopen() to open a file for writing, creating it if it doesn’t exist?
Show Answer
Explanation
51) What does fopen() return if the file cannot be opened?
Show Answer
Explanation
52) Which function is used to close an open file in C?
Show Answer
Explanation
53) What constant represents the end of a file in C standard I/O?
Show Answer
Explanation
54) Which header file contains math functions like sqrt() and pow()?
Show Answer
Explanation
-lm.55) Which of these functions reads a single character from standard input?
Show Answer
Explanation
56) What keyword is used to define an enumeration data type?
Show Answer
Explanation
enum Color { RED, GREEN, BLUE };. union is a different construct where members share memory.57) By default, what integer value is assigned to the first item in an enum?
Show Answer
Explanation
58) What is the result of 5 == 5 in a C condition evaluation?
Show Answer
Explanation
59) What value represents “false” in traditional C boolean evaluation?
Show Answer
Explanation
60) Which keyword is used in switch-case to handle unmatched values?
Show Answer
Explanation
61) What happens if a break statement is omitted at the end of a case in switch?
Show Answer
Explanation
62) What is the bitwise XOR operator in C?
Show Answer
Explanation
63) What is the bitwise NOT (complement) operator in C?
Show Answer
Explanation
64) What does the left shift operator << do to an integer?
Show Answer
Explanation
x << n) multiplies x by 2ⁿ, since each shift moves every bit to a higher place value. (Assuming no overflow.)65) What does the right shift operator >> do to a positive integer?
Show Answer
Explanation
x >> n) divides x by 2ⁿ, discarding the low-order bits. For unsigned values this is a logical shift (zero fill).66) What function appends one string to the end of another?
Show Answer
Explanation
67) What is a recursion in C?
Show Answer
Explanation
68) What is a pointer pointing to a memory location that has been freed called?
Show Answer
Explanation
69) What is an uninitialized pointer called?
Show Answer
Explanation
70) Which function reads formatted input from a file stream?
Show Answer
Explanation
71) Which function writes formatted output to a file stream?
Show Answer
Explanation
72) What is the purpose of fflush(stdin) or fflush(stdout)?
Show Answer
Explanation
73) What is the maximum number of dimensions an array can have in C?
Show Answer
Explanation
74) How do you declare a pointer to an integer in C?
Show Answer
Explanation
75) What is the output of sizeof(“Hello”) in bytes (including null terminator)?
Show Answer
Explanation
76) Which statement creates an array of 5 integers initialized to zero?
Show Answer
Explanation
77) What is the format specifier for printing pointer address in hexadecimal format?
Show Answer
Explanation
78) Which of these is a valid character constant in C?
Show Answer
Explanation
79) What is the escape sequence for a new line in C?
Show Answer
Explanation
80) What is the escape sequence for a tab space?
Show Answer
Explanation
81) What operator is used to calculate the size of a data type or variable in bytes?
Show Answer
Explanation
sizeof(int) or sizeof arr.82) Which of the following storage classes requests the compiler to store the variable in CPU register?
Show Answer
Explanation
83) What is the format specifier for unsigned int?
Show Answer
Explanation
84) What format specifier is used for long int?
Show Answer
Explanation
85) What function converts a string of digits into an integer?
Show Answer
Explanation
86) What is the preprocessor directive used to include header files?
Show Answer
Explanation
#include <stdio.h>. #import is an Objective-C / some-compiler extension, not standard C.87) Which loop tests the exit condition at the bottom after executing the loop body once?
Show Answer
Explanation
88) What is the output of !5 in C logical evaluation?
Show Answer
Explanation
89) What is the output of !0 in C?
Show Answer
Explanation
90) How is a function defined as receiving no arguments in C?
Show Answer
Explanation
91) What is the precedence order of arithmetic operators *, /, +, -?
Show Answer
Explanation
92) What keyword is used to specify that a variable can be modified unexpectedly by hardware/threads?
Show Answer
Explanation
93) What function moves the file position pointer to a specific location?
Show Answer
Explanation
94) What function returns the current file pointer position in a file stream?
Show Answer
Explanation
95) What function resets the file position pointer back to the beginning of the file?
Show Answer
Explanation
96) What standard macro in C denotes a null pointer constant?
Show Answer
Explanation
((void *)0).97) What operator is used to access structure members using a structure variable directly?
Show Answer
Explanation
emp.name. The arrow operator -> is used when you have a pointer to the struct.98) Which statement is true regarding C array parameters in functions?
Show Answer
Explanation
99) Which header file contains macro definitions like INT_MAX and INT_MIN?
Show Answer
Explanation
100) What is the result of applying bitwise NOT (~) on 0 in 32-bit two’s complement integer representation?
No Comments