-
What does the
fprintf()
function do in C?a) Reads formatted data from a file
b) Writes formatted data to a file
c) Reads formatted data from the console
d) Writes formatted data to the consoleAnswer: b) Writes formatted data to a file
-
In C, what does the
extern
keyword signify when used with a variable declaration?a) The variable is initialized with an external value
b) The variable is declared without any storage allocation
c) The variable is declared in another file and is available for use in the current file
d) The variable is of external linkageAnswer: c) The variable is declared in another file and is available for use in the current file
-
What will be the output of the following code snippet?
#include <stdio.h> int main() { int i = 5; printf("%d\n", i++); printf("%d\n", i); return 0; }
a) 5, 5
b) 5, 6
c) 6, 6
d) Compiler errorAnswer: b) 5, 6
-
Which function is used to copy a block of memory in C?
a) memcpy()
b) memmove()
c) strcpy()
d) strcat()Answer: a) memcpy()
-
What is the output of the following code?
#include <stdio.h> int main() { int arr[] = {1, 2, 3, 4, 5}; int *ptr = arr; printf("%d\n", *ptr++); printf("%d\n", *ptr); return 0; }
a) 1, 2
b) 1, 1
c) 2, 2
d) 2, 1Answer: a) 1, 2
-
Which of the following is NOT a valid format specifier for printing a double in C?
a) %f
b) %lf
c) %d
d) %eAnswer: c) %d
-
What will be the output of the following code?
#include <stdio.h> int main() { char str[6] = "Hello"; printf("%s\n", str); return 0; }
a) Hello
b) Hello!
c) Compiler error
d) Undefined behaviorAnswer: a) Hello
-
Which of the following statements is true about the
do-while
loop in C?a) The loop condition is checked before executing the loop body
b) The loop condition is checked after executing the loop body
c) The loop executes only if the condition is true
d) The loop always executes at least onceAnswer: d) The loop always executes at least once
-
What does the
putc()
function do in C?a) Reads a character from a file
b) Writes a character to a file
c) Reads a character from the console
d) Writes a character to the consoleAnswer: b) Writes a character to a file
-
What will be the output of the following code?
#include <stdio.h> int main() { int x = 10; int *ptr = &x; printf("%p\n", ptr); return 0; }
a) Address of x
b) Value of x
c) Address of ptr
d) Compiler errorAnswer: a) Address of x
Comments