1. Which of the following functions in C is used to read a single character from the standard input device? A) gets() B) getchar() C) scanf() D) readchar() Answer: B 2. What is the correct format specifier to print a floating-point number in exponential form? A) %f B) %lf C) %e D) %g Answer: C
1. Which of the following correctly states the C type used to store a single-precision IEEE-754 floating-point number? A) double B) float C) long double D) int Answer: B 2. In C, the literal 3.14 has what type by default? A) float B) double C) long double D) long long Answer: B 3. Which suffix
1. Consider: int a = 5; int b = ++a + a++;. What is the behavior according to the C standard? A) b == 12 and defined B) b == 11 and defined C) Undefined behavior (modifying a more than once without sequencing) D) b == 10 and defined Answer: C 2. Which expression yields
1. Which of the following is a declaration that also defines a variable in C? A) extern int x; B) int x; C) extern int x; /* in another file */ D) int; Answer: B 2. What is the value of a global variable with static storage that is not explicitly initialized? A) Indeterminate B)
1. Which of the following symbols is used to indicate a preprocessor directive in C? A) @ B) # C) $ D) % Answer: B 2. The #define directive in C is used for: A) Declaring a function B) Defining a macro or symbolic constant C) Including header files D) Declaring global variables Answer: B
1. Which of the following parameters are used in the main function to handle command line arguments in C? A) int argc, char *argv B) int argn, char **arglist C) int argc, char argv D) void argc, char *argv Answer: A 2. What does argc represent in a C program’s main function? A) Number of
1. Which header file is required for file handling in C? A) <stdio.h> B) <conio.h> C) <stdlib.h> D) <string.h> Answer: A 2. Which of the following modes opens a file for reading only? A) “w” B) “r” C) “a” D) “rw” Answer: B 3. What is the return type of fopen() function? A) int B)
1. Which of the following is the correct syntax to declare a function in C? A) return_type function_name(); B) function_name return_type(); C) function_name(); return_type D) return_type = function_name(); Answer: A 2. A function that calls itself is known as: A) Recursive Function B) Iterative Function C) Inline Function D) Macro Function Answer: A 3. What
1. Which of the following correctly declares a pointer to an integer in C? A) int p; B) int *p; C) int &p; D) int p*; Answer: B 2. What is the output of the following code? int x = 10; int *p = &x; printf(“%d”, *p); A) Address of x B) 10 C) Garbage
1. Which of the following correctly declares a modifiable string containing “hello”? A) char *s = “hello”; B) const char *s = “hello”; C) char s = “hello”; D) char s[5] = “hello”; Answer: C 2. What is the value returned by strlen(“abc\0def”)? A) 0 B) 3 C) 7 D) 6 Answer: B 3. Which