WorksheetsC Programming Multiple Choice Worksheet (Q1–Q20)
Total questions: 60
Worksheet time: 3600secs
History & Purpose: What was the primary motivation for creating the C programming language?
To develop the first general-purpose high-level language.
To provide a language for building graphical user interfaces.
To construct the Unix operating system.
To invent a language with automatic memory management.
Evolution: Which standard is considered the first standardized version of the C language?
C99
C11
C23
ANSI C (C89)
Application: C is fundamental in building operating systems and is also extensively used in which other area due to its ability to manage system resources efficiently and provide low-level memory access?
Web Design Frameworks
Embedded Systems and Microcontrollers
Artificial Intelligence and Machine Learning
High-level Business Application Software
Language vs. Programming Language: A Programming Language is best defined as:
A simple system for writing text documents.
A set of symbols for mathematical calculations.
A set of instructions for computers to execute, requiring strict syntax rules.
Any system of communication that is highly portable.
Execution Flow: In the C program execution process, what step occurs immediately after the Compiler translates the source code into assembly code?
Linker adds library code.
Loader loads the program into memory.
Execution runs the output.
Assembler turns the assembly code into machine code.
Compiler Function: Which of the following is NOT a stated function of a Compiler in C?
Translates high-level code into machine code.
Optimizes code for better performance.
Performs error checking during compilation.
Dynamically links external libraries during runtime.
Compilers: Which C compiler is described in the provided content as a legacy, educational compiler?
GCC
Clang
MSVC
Turbo C
Data Types Classification: Which of the following is an example of a User Defined Data Type in C?
int
array
pointer
union
Data Type Size: What is the typical size (in bytes) of a double data type in C?
2 bytes
4 bytes
8 bytes
16 bytes
Format Specifier: Which format specifier is used for a signed long long int?
%ld
%u
%lld
%Lf
Keywords: Which statement about C keywords is correct?
They can be used as variable names if capitalized.
They are user-defined words for specific tasks.
They are reserved words with special meanings and cannot be used as identifiers.
The compiler only throws an error if they are used as function names.
Scope Rules: A variable declared outside any block or function is known as a:
Local variable
Block variable
Global variable
Register variable
Scope Visibility: Local variables are visible in the block they are declared in and:
Only in the function where the block resides.
Other blocks nested inside that block.
All parts of the entire program.
Only in the lines of code following their declaration.
I/O Functions: Which C I/O function is generally considered unsafe because of its method for reading a string from standard input into a character array?
printf()
scanf()
gets()
puts()
I/O Functions: Which function is used to read formatted input from the console, typically from the user?
gets()
puts()
printf()
scanf()
Comments: What markers are used to enclose a Multi-line Comment in C?
// at the start of each line
$$
/* and */
# at the start of each line
Type Conversion: When an integer is added to a float, the integer is automatically converted to a float, and the result is a float. This typically happens automatically and is called:
Explicit Type Conversion
Typecasting
Implicit Type Conversion (Type Coercion)
Union Conversion
Type Conversion: Which of the following is the correct syntax for Explicit Type Conversion (typecasting) in C?
expression (datatype)
(expression) datatype
datatype (expression)
(datatype) expression
Preprocessor/Library: In the standard "Hello World" program, what is the purpose of #include
It marks the start of the program's execution.
It defines the printf function.
It includes the standard input-output library in the program.
It indicates the program ended successfully.
Escape Sequences: What is the primary purpose of using an escape sequence in a C string literal?
To denote the start of a variable.
To enable explicit type conversion.
To represent characters that cannot be used normally using the keyboard.
To perform error checking during compilation.
Unary Operators: If int a = 1; and int b = a++; what are the final values of a and b?
a is 1, b is 1
a is 2, b is 1
a is 2, b is 2
a is 1, b is 2
Unary Operators: If int a = 10; and int b = --a; what are the final values of a and b?
a is 10, b is 10
a is 10, b is 9
a is 9, b is 10
a is 9, b is 9
sizeof Operator: The sizeof operator in C is primarily used to:
Determine the data type of a variable at runtime
Find the size (in bytes) of a data type or variable
Allocate dynamic memory
Check if an array index is within bounds
Binary Operators: Which type of binary operator includes &&, ||, and !?
Relational Operators
Arithmetic Operators
Logical Operators
Bitwise Operators
Binary Operators: Which symbol represents the Bitwise XOR operator?
|
&
~
Assignment Operators: Which assignment operator is the shorthand for a = a + b?
a =+ b
a => b
a += b
a + b = a
Ternary Operator: The Ternary Operator (Conditional Operator) is a shorthand for:
for loop
do-while loop
switch statement
if-else statement
Expression Evaluation: What is the result of the expression 5 * 2 + 10 / 5?
10
12
14
20
Output Tracing: C int x = 5, y = 10, z = 0; if (x > 3 && y < 15) { z = 1; } if (x < 3 || y > 15) { z = 2; } printf("%d", z); What is the output?
0
1
2
3
Output Tracing: C int a = 5, b = 5; int c = a++ + ++b; printf("%d, %d, %d", a, b, c); What is the output?
5, 5, 10
6, 6, 12
6, 6, 11
5, 6, 11
Output Tracing: C int i = 10; printf("%d", i > 5 ? i : 5); What is the output?
5
10
15
0
Bitwise Operator: What is the result of the expression 12 & 5 (Bitwise AND)?
0
4
8
1
Bitwise Operator: What is the result of the expression 8 << 2 (Bitwise Left Shift)?
4
16
32
64
Operator Precedence: Given int x = 10, y = 20; what is the value of x after the expression x = y == 20; is evaluated?
10
20
1
0
Relational Operator: Which of the following is NOT a valid Relational Operator in C?
==
!=
=>
<
Control Statements: Control statements in C programming are instructions that primarily:
Define new data types
Declare variables in the global scope
Alter the sequential flow of execution within a program
Manage memory allocation and deallocation
Decision Making: The switch statement in C is typically used as an alternative to:
for loop
do-while loop
if-else-if ladder
goto statement
Output Tracing (if-else): C int num = 10; if (num > 10) { printf("A"); } else if (num == 10) { printf("B"); } else { printf("C"); } What is the output?
A
B
C
AB
Iteration: Which loop construct in C is guaranteed to execute its code block at least once, even if the condition is false from the start?
for loop
while loop
do-while loop
switch statement
Loop Syntax: Which statement best describes the purpose of the condition part in the for (initialization; condition; updation) syntax?
It is executed once at the start of the loop.
It is executed after each iteration to change the loop variable.
It is checked before each iteration; if false, the loop terminates.
It represents the body of the loop.
Output Tracing (break): C for (int i = 0; i < 5; i++) { if (i == 3) { break; } printf("%d", i); } What is the output?
01234
0123
012
0124
Output Tracing (continue): C for (int i = 1; i <= 4; i++) { if (i == 2) { continue; } printf("%d", i); } What is the output?
1234
12
134
124
Jump Statements: Which jump statement is used to transfer program control to a labeled statement within the same function?
break
continue
goto
return
Functions: What is the primary advantage of using functions to break down complex problems into smaller, manageable parts?
Improved compiler speed
Reduced need for data types
Modularity
Guaranteed use of call by reference
Function Types: The printf() and scanf() functions are examples of which type of C function?
User-Defined Functions
Recursive Functions
Inline Functions
Library Functions
Parameter Passing: In Pass By Value (Call By Value), what is passed to the function, and how does this affect the original argument?
The address of the argument is passed; the original value is affected.
A copy of the argument is passed; the original argument is NOT affected.
The expression itself is passed; the result is affected.
The variable name is passed; the function works on the original memory location.
Parameter Passing: The Pass By Reference technique uses which mechanism to receive the address of the data, allowing modification of the original value?
The inline keyword
The extern keyword
A pointer as a parameter
A function with no return value
Output Tracing (Call By Value): C void func(int val) { val = 123; } int main() { int x = 199; func(x); printf("%d", x); return 0; } What is the output?
123
0
199
Undefined behavior
Recursion: What is the purpose of the Base Case in a recursive function?
It is the part where the function calls itself with modified arguments.
It is only required for the factorial function.
It is the condition under which the recursion stops.
It calculates the final result before stack unwinding.
Function Pointers: What does a function pointer store?
The return value of a function.
The list of parameters of a function.
The memory address of a function.
The entire compiled code of a function.
Arrays: An array is a collection of elements that must all be of the:
Same name
Same size in memory (bytes)
Same data type
Same index value
Arrays: Array elements are stored in:
Dynamic memory locations
Scattered memory locations
Contiguous memory locations
Stack memory only
Array Indexing: In a 1D array of size N, what is the range of valid index values used to access its elements?
1 to N
1 to N-1
0 to N-1
0 to N
Array Memory: If an int variable takes 4 bytes, and arr[0] is located at memory address 1000, where would arr[2] be located in memory?
1004
1008
1012
1000
Array Disadvantages: A major disadvantage of arrays in C is that their size must be defined at the time of declaration, limiting flexibility. This is known as:
Homogeneous Data limitation
No Built-in Bounds Checking
Fixed Size limitation
Static Storage limitation
Array Disadvantages (Application): Which array operation is considered time-consuming because it typically requires shifting multiple elements in memory?
Accessing an element by index
Array traversal using a loop
Insertion or Deletion of elements
Calculating the array size using sizeof()
Arrays in Functions: When an array is passed to a function, C treats it as:
A new copy of the entire array.
A pointer to the last element.
A pointer to the first element of the array.
A structure containing the array data and size.
Inline Functions: The purpose of declaring a function as inline is to:
Ensure the function uses recursion.
Ask the compiler to replace the function call with its actual code at the call site to reduce overhead.
Prevent the function from being called multiple times.
Force the function to use pass by reference.
Function Pointer Syntax: In the declaration return_type (*pointer_name) (parameter_types);, why are the parentheses around *pointer_name necessary?
To denote that the pointer is an array of functions.
Otherwise, the compiler would treat it as a function declaration returning a return_type* (pointer).
To indicate that the function pointer uses an inline call.
To prevent the pointer from being assigned to any function.
Expression Components: In an expression like 8 + 78, the values 8 and 78 are classified as what?
Operators
Expressions
Operands
Variables
