-
What is the purpose of a type qualifier in C?
A) To specify the storage duration of a variable
B) To indicate the type of a variable
C) To modify the properties of a variable's type
D) To declare a constant variable
Answer: C) To modify the properties of a variable's type
-
Which C type qualifier is used to make a variable read-only?
A) mutable
B) constant
C) volatile
D) restrict
Answer: B) constant
-
What does the "volatile" type qualifier indicate in C?
A) It specifies a variable that cannot be modified
B) It indicates a variable that can be changed by external factors
C) It represents a constant variable
D) It defines a variable with automatic storage duration
Answer: B) It indicates a variable that can be changed by external factors
-
Which type qualifier is used to optimize code by informing the compiler that a variable does not alias with other pointers?
A) constant
B) restrict
C) volatile
D) mutable
Answer: B) restrict
-
What is the significance of the "mutable" type qualifier in C++?
A) It indicates a constant variable
B) It specifies a variable that cannot be modified
C) It allows modification of a variable in a constant context
D) It defines a variable with static storage duration
Answer: C) It allows modification of a variable in a constant context
-
Which type qualifier is often used for pointers to hardware registers in embedded systems programming?
A) mutable
B) constant
C) volatile
D) restrict
Answer: C) volatile
-
What is the difference between "const" and "volatile" type qualifiers in C?
A) "const" makes a variable read-only, while "volatile" indicates potential changes by external factors.
B) "const" and "volatile" are used interchangeably in C.
C) "const" specifies a constant variable, while "volatile" specifies an easily changeable variable.
D) "const" and "volatile" both make variables read-only.
Answer: A) "const" makes a variable read-only, while "volatile" indicates potential changes by external factors.
-
When should you use the "mutable" type qualifier in C++?
A) When you want to make a variable constant
B) When you need to modify a variable inside a constant member function
C) When you want to restrict the usage of a pointer
D) When you want to declare a global variable
Answer: B) When you need to modify a variable inside a constant member function
-
Which type qualifier is used to specify that a variable should have automatic storage duration?
A) const
B) auto
C) volatile
D) restrict
Answer: B) auto
-
What is the primary purpose of using type qualifiers in C?
A) To increase the performance of the code
B) To make code more readable
C) To modify the properties and behavior of variables
D) To declare data types in C
Answer: C) To modify the properties and behavior of variables
-
In C programming, what is a token?
A) A type of variable
B) A fundamental unit of the source code
C) A reserved word for functions
D) An error in the code
Answer: B) A fundamental unit of the source code
-
Which of the following is a valid token in C?
A) //comment
B) 1234.56
C) if-else
D) $variable
Answer: B) 1234.56
-
What does a C token consist of?
A) Only keywords
B) A sequence of characters
C) Variables and functions
D) Numbers and symbols
Answer: B) A sequence of characters
-
Which of the following is not a valid C identifier token?
A) my_variable
B) 123_variable
C) _underscore
D) variable123
Answer: B) 123_variable
-
What is the purpose of a string literal token in C?
A) To represent a sequence of characters enclosed in double quotes
B) To declare an integer variable
C) To specify a floating-point number
D) To define a function
Answer: A) To represent a sequence of characters enclosed in double quotes
-
Which token is used to represent integer values in C?
A) Identifier
B) Keyword
C) Integer Literal
D) Operator
Answer: C) Integer Literal
-
In C, what is the purpose of a macro token?
A) To declare a variable
B) To define a function
C) To perform arithmetic operations
D) To create a named constant
Answer: D) To create a named constant
-
Which token is used to represent a function call in C?
A) Identifier
B) Operator
C) Function Identifier
D) Parentheses
Answer: A) Identifier
-
What is the role of a preprocessor directive token in C?
A) To define a variable
B) To include header files
C) To declare a function
D) To perform bitwise operations
Answer: B) To include header files
-
Which of the following is not a valid C operator token?
A) +
B) ::
C) &&
D) or
Answer: D) or
-
What is the purpose of format specifiers in C?
A) To declare variables
B) To specify the format of input and output
C) To define functions
D) To create comments in the code
Answer: B) To specify the format of input and output
-
Which format specifier is used to print an integer in decimal notation?
A) %d
B) %f
C) %c
D) %s
Answer: A) %d
-
In C, what does the format specifier "%f" represent?
A) A character
B) A floating-point number
C) An integer
D) A string
Answer: B) A floating-point number
-
What format specifier is used to print a single character in C?
A) %d
B) %c
C) %s
D) %f
Answer: B) %c
-
Which format specifier is used to print a string in C?
A) %d
B) %c
C) %s
D) %f
Answer: C) %s
-
What is the format specifier for printing an unsigned integer in C?
A) %u
B) %d
C) %i
D) %x
Answer: A) %u
-
In C, how do you print a floating-point number with two decimal places?
A) %f
B) %.2f
C) %2f
D) %2.0f
Answer: B) %.2f
-
Which format specifier is used for printing in hexadecimal notation?
A) %h
B) %x
C) %o
D) %b
Answer: B) %x
-
What is the format specifier for printing an octal number in C?
A) %o
B) %x
C) %d
D) %u
Answer: A) %o
-
In C, how do you print a pointer address using a format specifier?
A) %p
B) %x
C) %s
D) %a
Answer: A) %p
-
In C, what is the purpose of an escape sequence?
A) To create comments in the code
B) To represent special characters in strings
C) To define functions
D) To declare variables
Answer: B) To represent special characters in strings
-
Which escape sequence is used to represent a newline character in C?
A) \n
B) \t
C) \r
D) \v
Answer: A) \n
-
What is the escape sequence for a tab character in C?
A) \n
B) \t
C) \r
D) \v
Answer: B) \t
-
Which escape sequence is used to represent a carriage return character in C?
A) \n
B) \t
C) \r
D) \v
Answer: C) \r
-
In C, how do you represent a backslash character in a string?
A) \\b
B) \b
C) \s
D) \c
Answer: A) \\b
-
What is the escape sequence for a single quotation mark (apostrophe) in C?
A) \'
B) \"
C) \a
D) \'
Answer: A) \'
-
Which escape sequence is used to represent a double quotation mark in C?
A) \'
B) \"
C) \a
D) \"
Answer: B) \"
-
What does the escape sequence \0 represent in C?
A) Null character
B) Newline character
C) Tab character
D) Carriage return character
Answer: A) Null character
-
In C, what is the purpose of the escape sequence \a?
A) To represent a backspace character
B) To create an alert or bell sound
C) To print a space character
D) To define an arithmetic operation
Answer: B) To create an alert or bell sound
-
Which escape sequence is used to represent a vertical tab character in C?
A) \v
B) \t
C) \r
D) \n
Answer: A) \v
-
What is the main purpose of the C preprocessor?
A) To execute C programs
B) To perform mathematical calculations
C) To preprocess source code before compilation
D) To handle user input
Answer: C) To preprocess source code before compilation
-
Which symbol is used to indicate a macro directive in C?
A) #
B) @
C) $
D) &
Answer: A) #
-
What does the #include directive do in C?
A) It defines a new function
B) It includes header files in the source code
C) It declares a variable
D) It prints output to the console
Answer: B) It includes header files in the source code
-
Which directive is used to define a macro in C?
A) #define
B) #include
C) #ifdef
D) #pragma
Answer: A) #define
-
What is the purpose of the #ifdef directive in C?
A) To check if a file exists
B) To define a new function
C) To conditionally include code based on a macro's existence
D) To declare a variable
Answer: C) To conditionally include code based on a macro's existence
-
In C, what does the #ifndef directive check for?
A) The presence of a function
B) The absence of a macro
C) The existence of a header file
D) The value of a variable
Answer: B) The absence of a macro
-
What is the purpose of the #undef directive in C?
A) To redefine a macro
B) To remove a macro definition
C) To include a header file
D) To print text to the console
Answer: B) To remove a macro definition
-
Which directive is used to include comments in the preprocessed code that are not visible in the final output?
A) #comment
B) #pragma
C) #ifdef
D) #error
Answer: B) #pragma
-
What does conditional compilation mean in the context of the C preprocessor?
A) Compiling code conditionally based on user input
B) Compiling code without any conditions
C) Compiling code to generate assembly language
D) Compiling code for debugging purposes
Answer: A) Compiling code conditionally based on user input
-
Which directive is used to generate error messages during preprocessing?
A) #error
B) #pragma
C) #include
D) #ifdef
Answer: A) #error