Wayground logo

Free Printable Worksheets

Font size

S
M
L
XL
Worksheets

C Programming Multiple Choice Worksheet (Q1–Q20)

Total questions: 60

Worksheet time: 3600secs

Name
Class
Date
1.

History & Purpose: What was the primary motivation for creating the C programming language?

a)

To develop the first general-purpose high-level language.

b)

To provide a language for building graphical user interfaces.

c)

To construct the Unix operating system.

d)

To invent a language with automatic memory management.

2.

Evolution: Which standard is considered the first standardized version of the C language?

a)

C99

b)

C11

c)

C23

d)

ANSI C (C89)

3.

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?

a)

Web Design Frameworks

b)

Embedded Systems and Microcontrollers

c)

Artificial Intelligence and Machine Learning

d)

High-level Business Application Software

4.

Language vs. Programming Language: A Programming Language is best defined as:

a)

A simple system for writing text documents.

b)

A set of symbols for mathematical calculations.

c)

A set of instructions for computers to execute, requiring strict syntax rules.

d)

Any system of communication that is highly portable.

5.

Execution Flow: In the C program execution process, what step occurs immediately after the Compiler translates the source code into assembly code?

a)

Linker adds library code.

b)

Loader loads the program into memory.

c)

Execution runs the output.

d)

Assembler turns the assembly code into machine code.

6.

Compiler Function: Which of the following is NOT a stated function of a Compiler in C?

a)

Translates high-level code into machine code.

b)

Optimizes code for better performance.

c)

Performs error checking during compilation.

d)

Dynamically links external libraries during runtime.

7.

Compilers: Which C compiler is described in the provided content as a legacy, educational compiler?

a)

GCC

b)

Clang

c)

MSVC

d)

Turbo C

8.

Data Types Classification: Which of the following is an example of a User Defined Data Type in C?

a)

int

b)

array

c)

pointer

d)

union

9.

Data Type Size: What is the typical size (in bytes) of a double data type in C?

a)

2 bytes

b)

4 bytes

c)

8 bytes

d)

16 bytes

10.

Format Specifier: Which format specifier is used for a signed long long int?

a)

%ld

b)

%u

c)

%lld

d)

%Lf

11.

Keywords: Which statement about C keywords is correct?

a)

They can be used as variable names if capitalized.

b)

They are user-defined words for specific tasks.

c)

They are reserved words with special meanings and cannot be used as identifiers.

d)

The compiler only throws an error if they are used as function names.

12.

Scope Rules: A variable declared outside any block or function is known as a:

a)

Local variable

b)

Block variable

c)

Global variable

d)

Register variable

13.

Scope Visibility: Local variables are visible in the block they are declared in and:

a)

Only in the function where the block resides.

b)

Other blocks nested inside that block.

c)

All parts of the entire program.

d)

Only in the lines of code following their declaration.

14.

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?

a)

printf()

b)

scanf()

c)

gets()

d)

puts()

15.

I/O Functions: Which function is used to read formatted input from the console, typically from the user?

a)

gets()

b)

puts()

c)

printf()

d)

scanf()

16.

Comments: What markers are used to enclose a Multi-line Comment in C?

a)

// at the start of each line

b)

$$

c)

/* and */

d)

# at the start of each line

17.

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:

a)

Explicit Type Conversion

b)

Typecasting

c)

Implicit Type Conversion (Type Coercion)

d)

Union Conversion

18.

Type Conversion: Which of the following is the correct syntax for Explicit Type Conversion (typecasting) in C?

a)

expression (datatype)

b)

(expression) datatype

c)

datatype (expression)

d)

(datatype) expression

19.

Preprocessor/Library: In the standard "Hello World" program, what is the purpose of #include ?

a)

It marks the start of the program's execution.

b)

It defines the printf function.

c)

It includes the standard input-output library in the program.

d)

It indicates the program ended successfully.

20.

Escape Sequences: What is the primary purpose of using an escape sequence in a C string literal?

a)

To denote the start of a variable.

b)

To enable explicit type conversion.

c)

To represent characters that cannot be used normally using the keyboard.

d)

To perform error checking during compilation.

21.

Unary Operators: If int a = 1; and int b = a++; what are the final values of a and b?

a)

a is 1, b is 1

b)

a is 2, b is 1

c)

a is 2, b is 2

d)

a is 1, b is 2

22.

Unary Operators: If int a = 10; and int b = --a; what are the final values of a and b?

a)

a is 10, b is 10

b)

a is 10, b is 9

c)

a is 9, b is 10

d)

a is 9, b is 9

23.

sizeof Operator: The sizeof operator in C is primarily used to:

a)

Determine the data type of a variable at runtime

b)

Find the size (in bytes) of a data type or variable

c)

Allocate dynamic memory

d)

Check if an array index is within bounds

24.

Binary Operators: Which type of binary operator includes &&, ||, and !?

a)

Relational Operators

b)

Arithmetic Operators

c)

Logical Operators

d)

Bitwise Operators

25.

Binary Operators: Which symbol represents the Bitwise XOR operator?

a)

|

b)

&

c)

~

d)

26.

Assignment Operators: Which assignment operator is the shorthand for a = a + b?

a)

a =+ b

b)

a => b

c)

a += b

d)

a + b = a

27.

Ternary Operator: The Ternary Operator (Conditional Operator) is a shorthand for:

a)

for loop

b)

do-while loop

c)

switch statement

d)

if-else statement

28.

Expression Evaluation: What is the result of the expression 5 * 2 + 10 / 5?

a)

10

b)

12

c)

14

d)

20

29.

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?

a)

0

b)

1

c)

2

d)

3

30.

Output Tracing: C int a = 5, b = 5; int c = a++ + ++b; printf("%d, %d, %d", a, b, c); What is the output?

a)

5, 5, 10

b)

6, 6, 12

c)

6, 6, 11

d)

5, 6, 11

31.

Output Tracing: C int i = 10; printf("%d", i > 5 ? i : 5); What is the output?

a)

5

b)

10

c)

15

d)

0

32.

Bitwise Operator: What is the result of the expression 12 & 5 (Bitwise AND)?

a)

0

b)

4

c)

8

d)

1

33.

Bitwise Operator: What is the result of the expression 8 << 2 (Bitwise Left Shift)?

a)

4

b)

16

c)

32

d)

64

34.

Operator Precedence: Given int x = 10, y = 20; what is the value of x after the expression x = y == 20; is evaluated?

a)

10

b)

20

c)

1

d)

0

35.

Relational Operator: Which of the following is NOT a valid Relational Operator in C?

a)

==

b)

!=

c)

=>

d)

<

36.

Control Statements: Control statements in C programming are instructions that primarily:

a)

Define new data types

b)

Declare variables in the global scope

c)

Alter the sequential flow of execution within a program

d)

Manage memory allocation and deallocation

37.

Decision Making: The switch statement in C is typically used as an alternative to:

a)

for loop

b)

do-while loop

c)

if-else-if ladder

d)

goto statement

38.

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)

A

b)

B

c)

C

d)

AB

39.

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?

a)

for loop

b)

while loop

c)

do-while loop

d)

switch statement

40.

Loop Syntax: Which statement best describes the purpose of the condition part in the for (initialization; condition; updation) syntax?

a)

It is executed once at the start of the loop.

b)

It is executed after each iteration to change the loop variable.

c)

It is checked before each iteration; if false, the loop terminates.

d)

It represents the body of the loop.

41.

Output Tracing (break): C for (int i = 0; i < 5; i++) { if (i == 3) { break; } printf("%d", i); } What is the output?

a)

01234

b)

0123

c)

012

d)

0124

42.

Output Tracing (continue): C for (int i = 1; i <= 4; i++) { if (i == 2) { continue; } printf("%d", i); } What is the output?

a)

1234

b)

12

c)

134

d)

124

43.

Jump Statements: Which jump statement is used to transfer program control to a labeled statement within the same function?

a)

break

b)

continue

c)

goto

d)

return

44.

Functions: What is the primary advantage of using functions to break down complex problems into smaller, manageable parts?

a)

Improved compiler speed

b)

Reduced need for data types

c)

Modularity

d)

Guaranteed use of call by reference

45.

Function Types: The printf() and scanf() functions are examples of which type of C function?

a)

User-Defined Functions

b)

Recursive Functions

c)

Inline Functions

d)

Library Functions

46.

Parameter Passing: In Pass By Value (Call By Value), what is passed to the function, and how does this affect the original argument?

a)

The address of the argument is passed; the original value is affected.

b)

A copy of the argument is passed; the original argument is NOT affected.

c)

The expression itself is passed; the result is affected.

d)

The variable name is passed; the function works on the original memory location.

47.

Parameter Passing: The Pass By Reference technique uses which mechanism to receive the address of the data, allowing modification of the original value?

a)

The inline keyword

b)

The extern keyword

c)

A pointer as a parameter

d)

A function with no return value

48.

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?

a)

123

b)

0

c)

199

d)

Undefined behavior

49.

Recursion: What is the purpose of the Base Case in a recursive function?

a)

It is the part where the function calls itself with modified arguments.

b)

It is only required for the factorial function.

c)

It is the condition under which the recursion stops.

d)

It calculates the final result before stack unwinding.

50.

Function Pointers: What does a function pointer store?

a)

The return value of a function.

b)

The list of parameters of a function.

c)

The memory address of a function.

d)

The entire compiled code of a function.

51.

Arrays: An array is a collection of elements that must all be of the:

a)

Same name

b)

Same size in memory (bytes)

c)

Same data type

d)

Same index value

52.

Arrays: Array elements are stored in:

a)

Dynamic memory locations

b)

Scattered memory locations

c)

Contiguous memory locations

d)

Stack memory only

53.

Array Indexing: In a 1D array of size N, what is the range of valid index values used to access its elements?

a)

1 to N

b)

1 to N-1

c)

0 to N-1

d)

0 to N

54.

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?

a)

1004

b)

1008

c)

1012

d)

1000

55.

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:

a)

Homogeneous Data limitation

b)

No Built-in Bounds Checking

c)

Fixed Size limitation

d)

Static Storage limitation

56.

Array Disadvantages (Application): Which array operation is considered time-consuming because it typically requires shifting multiple elements in memory?

a)

Accessing an element by index

b)

Array traversal using a loop

c)

Insertion or Deletion of elements

d)

Calculating the array size using sizeof()

57.

Arrays in Functions: When an array is passed to a function, C treats it as:

a)

A new copy of the entire array.

b)

A pointer to the last element.

c)

A pointer to the first element of the array.

d)

A structure containing the array data and size.

58.

Inline Functions: The purpose of declaring a function as inline is to:

a)

Ensure the function uses recursion.

b)

Ask the compiler to replace the function call with its actual code at the call site to reduce overhead.

c)

Prevent the function from being called multiple times.

d)

Force the function to use pass by reference.

59.

Function Pointer Syntax: In the declaration return_type (*pointer_name) (parameter_types);, why are the parentheses around *pointer_name necessary?

a)

To denote that the pointer is an array of functions.

b)

Otherwise, the compiler would treat it as a function declaration returning a return_type* (pointer).

c)

To indicate that the function pointer uses an inline call.

d)

To prevent the pointer from being assigned to any function.

60.

Expression Components: In an expression like 8 + 78, the values 8 and 78 are classified as what?

a)

Operators

b)

Expressions

c)

Operands

d)

Variables