76. What does the atoi()
function do?
A) Converts an integer to a string
B) Converts a string to an integer
C) Allocates memory
D) Copies a string
Answer: B) Converts a string to an integer
77. Which function terminates the program immediately?
A) exit()
B) terminate()
C) stop()
D) abort()
Answer: A) exit()
78. Which keyword is used for defining constants in C?
A) define
B) const
C) constant
D) static
Answer: B) const
79. What is the output of printf("%d", 5 ^ 3);
?
A) 2
B) 6
C) 7
D) 8
Answer: C) 6
80. What is the result of printf("%d", ~0);
?
A) -1
B) 0
C) 1
D) Undefined
Answer: A) -1
81. What will be the value of sizeof("Hello")
in C?
A) 5
B) 6
C) 4
D) Compiler-dependent
Answer: B) 6
82. What does fopen("file.txt", "w")
do if the file exists?
A) Appends data to the file
B) Opens file without changes
C) Overwrites the file
D) Generates an error
Answer: C) Overwrites the file
83. Which function is used to compare two strings in C?
A) strcmp()
B) strcomp()
C) strcompare()
D) compare()
Answer: A) strcmp()
84. What is the use of static
keyword for variables?
A) The variable retains its value between function calls
B) The variable is globally accessible
C) The variable cannot be changed
D) None of the above
Answer: A) The variable retains its value between function calls
85. What will be the output of printf("%c", 65);
?
A) 65
B) A
C) a
D) Compilation error
Answer: B) A
86. What is the default value of an uninitialized local variable in C?
A) 0
B) Garbage value
C) NULL
D) Depends on compiler
Answer: B) Garbage value
87. Which function is used to get the length of a string in C?
A) strlen()
B) size()
C) length()
D) count()
Answer: A) strlen()
88. What will be the output of printf("%d", 'A' + 1);
?
A) 65
B) 66
C) A1
D) Compilation error
Answer: B) 66
89. Which statement is used to terminate a loop in C?
A) stop
B) exit
C) break
D) continue
Answer: C) break
90. What is the result of printf("%d", 5 >> 1);
?
A) 2
B) 2.5
C) 3
D) 10
Answer: A) 2
91. Which keyword is used to define a function in C?
A) def
B) function
C) void
D) None of the above
Answer: D) None of the above
92. What will be the output of printf("%d", 7 % 2);
?
A) 3
B) 1
C) 2
D) 0
Answer: B) 1
93. How do you declare a constant integer in C?
A) const int a = 10;
B) int const a = 10;
C) Both A and B
D) None of the above
Answer: C) Both A and B
94. What is the function of rewind()
in C?
A) Moves the file pointer to the end
B) Moves the file pointer to the beginning
C) Moves the file pointer to the middle
D) None of the above
Answer: B) Moves the file pointer to the beginning
95. Which operator is used for bitwise OR operation?
A) |
B) ||
C) &
D) &&
Answer: A) |
96. What will be the output of printf("%d", sizeof(0.5));
?
A) 4
B) 8
C) 2
D) Compiler-dependent
Answer: B) 8
97. How is memory allocated for an array in C?
A) malloc()
B) calloc()
C) new
D) Both A and B
Answer: D) Both A and B
98. What is the return type of malloc()
in C?
A) int*
B) void*
C) char*
D) float*
Answer: B) void*
99. What will be the output of printf("%d", 5 << 1);
?
A) 10
B) 2
C) 3
D) 0
Answer: A) 10
100. Which header file is required for memory allocation functions like malloc()
?
A) <memory.h>
B) <alloc.h>
C) <stdlib.h>
D) <malloc.h>
Answer: C) <stdlib.h>