- register
- static
- constant
Explanation:
The correct answer is d. In C, auto, register, and static are storage class specifiers; constant is not. The correct term is const, which is a type qualifier.
- Which of the following is the correct initialization of a 2d array with 2 digits and 3 digits?
- int arr[2, 3];
- int arr2={{1,2,3},{4,5,6}};
- int arr={1,2,3,4,5,6};
- int arr2={1,2,3,4,5,6};
Explanation:
The correct answer is b. The proper approach to initialize a 2D array is to specify its dimensions and provide the values for each row in curly brackets.
- Which of the following claims regarding C's recursion is accurate?
- The base case is a requirement for all recursive functions.
- Iterating is never more efficient than recursion.
- Only integer functions can be utilized with recursion.
- In C, recursion is disallowed.
Explanation:
The right choice is option a. Without a base case to stop a recursive function, there is a possibility of indefinite iteration and stack overflow.
- What is the outcome of the expression printf("%d", sizeof('A'));?
- It varies based on the platform.
Explanation:
The correct answer is a. The sizeof the operator in C returns the size of a char, typically 1 byte, when applied to characters such as 'A'. Character literals are usually of type int, but it evaluates to char instead of sizeof('A').
- What header files are needed to use the C malloc function?
- stdlib.h
- stdio.h
- string.h
- math.h
Explanation:
The correct answer is a. The stdlib.h header file is needed for dynamic memory allocations using the malloc function.
- Which of the following options best describes the function of the #define preprocessor command in C?
- A function is defined.
- A macro is defined.
- A header file is included.
- A variable is initialized.
Explanation:
The correct answer is b. The macro is a piece of code that is preprocessor-replaced before the compilation has been done and it is defined with the #define directive.
- Which operator in C has the most priority among the following?
- (multiplication)
- + (addition)
- && (logical AND)
- == (equality)
Explanation:
The correct answer is a. In C, the multiplication operator * takes precedence over the sum operator +, the logical AND && operator, and the parity == operator. Operations in a term are determined by precedence.
- Which is the right way to declare a function that returns a pointer to a character and accepts an integer pointer as an argument in C?
- char *func(int ptr);
- char func(int *ptr);
- char func(int ptr);
- char (func)(int );
Explanation:
The correct answer is b. The char func(intptr); is a valid declaration of a function that accepts an integer pointer and returns a character pointer.
- Which of the following describes the primary function of the typedef keyword in C?
- To define an additional variable
- To define a new data type
- To create an alias for an existing datatype.
- To define other functions.
Explanation:
The correct answer is c. We can create a new name(alias) for an already existing data type using the typedef keyword in C.
- Which of the following best summarizes the extern keyword in C?
- A local variable is defined.
- A variable is declared but not defined.
- A change has been initiated.
- Memory is allocated for the variable.
Explanation:
The correct answer is b. In order to grant access to variables in a particular file, the extern keyword in C is used to declare a variable defined in a different source file or scope
- What does C's #pragma directive aim to achieve?
- To include all available libraries.
- To provide the compiler with extra instructions.
- To define macros.
- To declare transactions.
Explanation:
The right choice is option b. Within the C programming language, the #pragma directive plays a crucial role in offering additional details to the compiler, typically concerning the management of the source code, like specifying warning operations or optimization strategies. When the logical expression ! (1 && 0) is employed, it results in a syntax error.
Explanation:
The correct answer is b. Because logical AND (&&) requires both operands to be true, Equation 1 && 0 evaluates to 0. For 0 to be logically NOT(!) is 1.
- Which of the below C functions reads a single character from the console?
- scanf
- printf
- getchar
- putchar
Explanation: