-
What does ASCII stand for in the context of computer programming?
A) American Standard Code for Information Interchange
B) Advanced System Character Input Interface
C) Automated System Code for Information Integration
D) All-System Code for Input and Output
Answer: A) American Standard Code for Information Interchange
-
How many bits are typically used to represent a character in ASCII?
A) 4 bits
B) 8 bits
C) 16 bits
D) 32 bits
Answer: B) 8 bits
-
What is the ASCII value of the lowercase letter 'a'?
A) 65
B) 97
C) 48
D) 32
Answer: B) 97
-
Which ASCII value represents the space character?
A) 32
B) 48
C) 64
D) 96
Answer: A) 32
-
What is the ASCII value of the digit '5'?
A) 53
B) 49
C) 51
D) 55
Answer: A) 53
-
Which ASCII code represents the newline character?
A) 10
B) 13
C) 8
D) 32
Answer: A) 10
-
What is the ASCII value of the uppercase letter 'Z'?
A) 65
B) 97
C) 90
D) 122
Answer: C) 90
-
Which ASCII value represents the backspace control character?
A) 7
B) 9
C) 8
D) 10
Answer: C) 8
-
What is the ASCII value of the special character '@'?
A) 33
B) 42
C) 64
D) 90
Answer: C) 64
-
Which ASCII code represents the carriage return character?
A) 10
B) 13
C) 8
D) 32
Answer: B) 13
-
What is the main purpose of the static
keyword in C?
A) To define a constant value
B) To declare a variable as global
C) To specify a function as static
D) To control the visibility and lifetime of a variable
Answer: D) To control the visibility and lifetime of a variable
-
Where can you use the static
keyword in C?
A) Only with global variables
B) Only with local variables inside a function
C) Both with global and local variables
D) Only with function declarations
Answer: C) Both with global and local variables
-
What is the lifetime of a static
variable declared inside a function?
A) It is destroyed when the function returns
B) It persists throughout the program's execution
C) It is destroyed when the program terminates
D) It has a limited lifetime of one function call
Answer: B) It persists throughout the program's execution
-
How does the static
keyword affect the visibility of a global variable?
A) It makes the variable accessible only within the declaring source file
B) It makes the variable accessible from any source file
C) It hides the variable from the entire program
D) It has no effect on the visibility of global variables
Answer: A) It makes the variable accessible only within the declaring source file
-
What is the initial value of a static
variable if not explicitly initialized?
A) The variable remains uninitialized
B) It is set to 0 by default
C) It is initialized to the value of the last variable in memory
D) It is initialized to the ASCII value of 'A'
Answer: B) It is set to 0 by default
-
When is memory allocated for a static
variable?
A) At the beginning of the program
B) At the end of the program
C) Only when the variable is accessed for the first time
D) Memory allocation for static
variables is not required
Answer: A) At the beginning of the program
-
What is the primary benefit of using a static
function in C?
A) It allows the function to be called from any source file
B) It improves the function's runtime performance
C) It restricts the function's access to global variables
D) It limits the function's scope to the declaring source file
Answer: D) It limits the function's scope to the declaring source file
-
In a multi-threaded program, how does the static
keyword affect variable access?
A) It allows multiple threads to access the variable concurrently
B) It restricts access to a single thread at a time
C) It prevents variables from being shared across threads
D) It has no impact on multi-threaded programs
Answer: B) It restricts access to a single thread at a time
-
What is the primary use of a static
variable inside a function?
A) To make it accessible from other functions
B) To create a local constant value
C) To maintain state across function calls
D) To improve the function's runtime performance
Answer: C) To maintain state across function calls
-
What happens when you declare a static
variable with the same name in different functions?
A) It creates separate instances of the variable in each function
B) It results in a compilation error
C) It creates a global variable accessible from both functions
D) It has no effect on variable scope
Answer: A) It creates separate instances of the variable in each function
-
What is the purpose of a C compiler?
A) To execute C programs
B) To interpret C code
C) To translate C source code into machine code
D) To debug C programs
Answer: C) To translate C source code into machine code
-
When does a C compiler generate compiler errors?
A) During code execution
B) During code debugging
C) During the compilation process
D) After the program terminates
Answer: C) During the compilation process
-
What type of error occurs when there is a syntax mistake in C code?
A) Linker error
B) Runtime error
C) Compiler error
D) Logical error
Answer: C) Compiler error
-
Which of the following compiler errors is related to using an undeclared variable?
A) Syntax error
B) Semantic error
C) Type error
D) Identifier not found error
Answer: D) Identifier not found error
-
What does a "missing semicolon" compiler error indicate in C?
A) A problem with the code's logic
B) A missing header file
C) A missing closing brace
D) A missing statement terminator
Answer: D) A missing statement terminator
-
What is a "type mismatch" compiler error in C?
A) When the code has a logical error
B) When there is a mismatch between a variable's data type and its usage
C) When there are too many comments in the code
D) When the code has a missing include directive
Answer: B) When there is a mismatch between a variable's data type and its usage
-
Which compiler error occurs when you attempt to assign a value to a constant?
A) Type error
B) Syntax error
C) Semantic error
D) Constant assignment error
Answer: C) Semantic error
-
What is the purpose of the C preprocessor in handling compiler errors?
A) To generate error messages
B) To highlight compiler errors in the code
C) To include header files
D) To optimize code for better performance
Answer: A) To generate error messages
-
When might a "multiple definition" compiler error occur?
A) When a variable is declared but not defined
B) When a function is declared but not used
C) When the same function or variable is defined in multiple source files
D) When there are too many comments in the code
Answer: C) When the same function or variable is defined in multiple source files
-
What is the role of a linker in the context of compiler errors?
A) To report syntax errors
B) To resolve external references and produce the final executable
C) To optimize code for execution
D) To execute the program
Answer: B) To resolve external references and produce the final executable
-
What are compiler warnings in C?
A) Errors that halt the compilation process
B) Messages indicating potential issues in the code
C) Fatal errors that terminate the program
D) Debugging information generated by the compiler
Answer: B) Messages indicating potential issues in the code
-
Why are compiler warnings important in C programming?
A) They provide information about program execution.
B) They help improve program performance.
C) They identify code that may lead to errors or unintended behavior.
D) They are used for documentation purposes.
Answer: C) They identify code that may lead to errors or unintended behavior.
-
Which option can be used with most C compilers to enable additional warnings?
A) -e
B) -w
C) -Wall
D) -error
Answer: C) -Wall
-
What does the "unused variable" warning indicate?
A) The variable is not declared.
B) The variable is declared but never used in the code.
C) The variable is used without declaration.
D) The variable has an incorrect data type.
Answer: B) The variable is declared but never used in the code.
-
When might you encounter a "uninitialized variable" warning?
A) When a variable is declared and initialized correctly.
B) When a variable is declared and used without initialization.
C) When a variable is declared but not used.
D) When a variable is declared inside a function.
Answer: B) When a variable is declared and used without initialization.
-
What does the "implicit conversion" warning suggest in C?
A) A type mismatch error in the code.
B) An optimization opportunity.
C) A potential buffer overflow issue.
D) A missing include directive.
Answer: A) A type mismatch error in the code.
-
Which warning may be issued when a function is declared but not defined in the code?
A) "Infinite loop detected"
B) "Function prototype mismatch"
C) "Unused function"
D) "Missing semicolon"
Answer: C) "Unused function"
-
What should you do when you encounter a compiler warning in your C code?
A) Ignore it; warnings are not important.
B) Disable all warnings to speed up compilation.
C) Investigate and address the issue indicated by the warning.
D) Report the warning to the compiler developer.
Answer: C) Investigate and address the issue indicated by the warning.
-
Which compiler option can be used to treat warnings as errors, halting compilation if any warnings are present?
A) -Wall
B) -Werror
C) -Wformat
D) -Wunused-variable
Answer: B) -Werror
-
In a well-structured C program, what is the ideal goal regarding compiler warnings?
A) To eliminate all warnings and have a clean compilation.
B) To generate as many warnings as possible for thorough code analysis.
C) To ignore warnings and focus on fixing errors.
D) To disable all warnings for faster compilation.
Answer: A) To eliminate all warnings and have a clean compilation.
-
What are linker errors in C programming?
A) Errors that occur during program execution
B) Errors related to the linking stage of compilation
C) Errors caused by logical mistakes in the code
D) Errors that are reported by the preprocessor
Answer: B) Errors related to the linking stage of compilation
-
When do linker errors typically occur in the C compilation process?
A) During the preprocessing stage
B) During the compilation stage
C) During the linking stage
D) During runtime execution
Answer: C) During the linking stage
-
Which of the following is a common linker error?
A) Syntax error
B) Type mismatch error
C) Undefined reference error
D) Memory allocation error
Answer: C) Undefined reference error
-
What does an "undefined reference" linker error indicate?
A) A function or variable is declared but not defined in the code.
B) There is a syntax error in the code.
C) The code contains a memory leak.
D) The code has an infinite loop.
Answer: A) A function or variable is declared but not defined in the code.
-
Which tool is responsible for performing the linking process in C?
A) Compiler
B) Debugger
C) Linker
D) Preprocessor
Answer: C) Linker
-
How can you resolve an "undefined reference" linker error?
A) Ignore the error; it's not important.
B) Add the missing function or variable definition to your code.
C) Delete the reference to the undefined entity.
D) Disable linker checks in the compiler settings.
Answer: B) Add the missing function or variable definition to your code.
-
What is the purpose of linking in C?
A) To detect syntax errors
B) To combine multiple source code files into an executable program
C) To optimize code for execution
D) To generate debugging information
Answer: B) To combine multiple source code files into an executable program
-
Which phase of the compilation process checks for linker errors?
A) Preprocessing
B) Compilation
C) Assembly
D) Linking
Answer: D) Linking
-
In which part of a C program would you typically find linker errors?
A) In the main function
B) In the header files
C) In external libraries or function calls
D) In comments and documentation
Answer: C) In external libraries or function calls
-
What does the linker do when it encounters an "undefined reference" error?
A) It automatically defines the missing entity.
B) It halts the compilation process.
C) It generates a runtime error.
D) It searches for the missing entity in system libraries.
Answer: B) It halts the compilation process.