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
1. Which of the following best describes a union in C? A) A collection of named bit-fields only B) A type whose members share the same memory location C) A type that can hold multiple values simultaneously D) A function-like macro for grouping variables Answer: B 2. If a union has members of sizes 4,
1. Consider: struct S { int a; char b; double c; }; What is the most likely value of sizeof(struct S) under the stated assumptions? A) 13 B) 16 C) 24 D) 32 Answer: C 2. Which of the following is not a valid way to initialize a structure struct P { int x; int
Q1. Which of the following correctly declares a one-dimensional array of 50 integers in C? A) int a(50); B) int a[50]; C) int a = [50]; D) int a{50}; Answer: B Q2. Given int a[10];, what is the valid index range for accessing elements? A) 0 to 9 B) 1 to 10 C) -1 to
1. Which of the following correctly declares a function that takes an int and returns a pointer to char? A) char *f(int); B) char (*f)(int); C) char *f(int*); D) char f*(int); Answer: A 2. In C, a function prototype must appear before its use to: A) allocate memory for the function B) inform the compiler