computer MCQs

12th • Chapter 13

49 Questions TextBook
1

What is a self-contained piece of code that performs a specific task?

A
A variable
B
A function
C
A loop
D
A header file
2

The programming approach of dividing program logic into smaller modules is known as?

A
Unstructured programming
B
Object-oriented programming
C
Structured programming
D
Procedural programming
3

Which of the following is a primary benefit of using functions?

A
Increases program size
B
Decreases code reusability
C
Makes programs easier to understand and maintain
D
Makes debugging harder
4

Pre-defined functions like printf() and scanf() are packaged in?

A
Source files
B
Object files
C
Libraries
D
Executables
5

To use a built-in function in C, you must include the corresponding ___ in your program.

A
source file
B
header file
C
text file
D
object file
6

Functions that are written by the programmer to solve a specific problem are called?

A
Built-in functions
B
Library functions
C
Standard functions
D
User-defined functions
7

What are the three parts of a function header?

A
Return type, name, body
B
Name, parameters, body
C
Return type, name, parameters
D
Return type, parameters, body
8

The part of the function where variable declarations and program logic are implemented is called the?

A
Function header
B
Function prototype
C
Function call
D
Function body
9

Which statement is used to specify the value returned by a function?

A
void
B
exit
C
return
D
break
10

What is a function prototype?

A
The function's logic
B
A statement providing basic information about the function to the compiler
C
Another name for the function body
D
The execution of the function
11

A function prototype statement must end with which character?

A
A colon (:)
B
A period (.)
C
Curly braces {}
D
A semicolon (;)
12

What is the mechanism used to invoke a function to perform a specific task?

A
Function definition
B
Function prototype
C
Function call
D
Function declaration
13

The duration for which a variable exists in memory is called its?

A
scope
B
region
C
lifetime
D
space
14

The region of a program in which a variable is accessible is known as its?

A
lifetime
B
scope
C
block
D
boundary
15

Variables declared within a block or a function are called?

A
Global variables
B
Static variables
C
External variables
D
Local variables
16

Variables declared outside of all functions are known as?

A
Local variables
B
Block variables
C
Global variables
D
Auto variables
17

What is the lifetime of a global variable?

A
Until the function in which it is declared ends
B
Until the block in which it is declared ends
C
Until the program terminates
D
Only for the duration of a loop
18

In the context of function calls, the parameters passed in the function call are known as?

A
Formal parameters
B
Dummy arguments
C
Actual parameters
D
Local parameters
19

The parameters specified in the function header are called?

A
Actual arguments
B
Global arguments
C
Calling arguments
D
Formal arguments
20

Formal arguments are also known as?

A
Actual arguments
B
Referenced arguments
C
Original arguments
D
Dummy arguments
21

What happens to a local variable when the program control moves outside the block in which it is declared?

A
It becomes global
B
Its value is saved
C
It is destroyed
D
It becomes static
22

Memory is allocated to a local variable at the time of its?

A
destruction
B
definition
C
first reference
D
declaration
23

Which of the following looks for the prototypes of functions used in a program?

A
linker
B
loader
C
parser
D
compiler
24

The name of actual and formal parameters?

A
must be same
B
must be different
C
may or may not be same
D
must be in lowercase
25

Which of the following is true about a function call?

A
It stops the execution of the program
B
It transfers control to the called function
C
It transfers control to the main function
D
It resumes the execution of the program
26

Global variables are created in?

A
ROM
B
Cache
C
Hard disk
D
RAM
27

Which library contains the definition for printf() and scanf()?

A
conio.h
B
math.h
C
stdio.h
D
ctype.h
28

In C, how are arguments passed to a function by default?

A
By reference
B
By pointer
C
By value
D
By address
29

What is the maximum number of values a function can return using a single 'return' statement?

A
Two
B
One
C
As many as needed
D
Zero
30

The idea of modular programming is inspired by?

A
Software development
B
Hardware manufacturing
C
Database design
D
Network architecture
31

In a structured program, the main function primarily consists of?

A
A series of function calls
B
Countless lines of code
C
Variable declarations only
D
Looping structures
32

When an error arises in a structured program, it is best to debug?

A
The whole program
B
The main function only
C
The infected function only
D
The header files
33

The function header `void calculate()` indicates?

A
It returns an int and takes no arguments
B
It returns nothing and takes no arguments
C
It returns a void pointer
D
It has a syntax error
34

If a return type is `void`, the function body?

A
Must contain a return statement
B
Does not need a return statement
C
Must return 0
D
Must return null
35

Where are function prototypes usually placed?

A
At the end of the source file
B
Inside the main function
C
In a separate .obj file
D
At the beginning of the source file, before main()
36

When a function call is executed, control transfers to?

A
The next line in the calling function
B
The called function
C
The operating system
D
The compiler
37

The scope of a local variable starts from its point of declaration and ends at?

A
The end of the program
B
The end of the function call
C
The end of the block containing its declaration
D
The next declaration
38

The variable `chk` in the `if` block of Example 1 (page 212) has what kind of scope?

A
Global scope
B
Function scope
C
File scope
D
Block scope
39

Attempting to refer to a variable outside its scope results in a?

A
Runtime error
B
Logical error
C
Compiler error
D
Warning
40

What is the value of `nCount` printed at the end of the program in Example 2 (page 214)?

A
0
B
10
C
6
D
5
41

In the `Add(int n1, int n2)` function, `n1` and `n2` are?

A
Global variables
B
Actual parameters
C
Static variables
D
Formal parameters
42

Any change made to the value of a formal parameter ___ affect the value of the actual parameter.

A
directly
B
does not
C
always
D
might
43

A built-in function, once defined by the C standard library,?

A
can be redefined by the user
B
cannot be redefined by the user
C
must be redefined by the user
D
is an optional feature
44

In a C program, two different functions can have?

A
The same name and same parameters
B
The same name but different parameters
C
Different names but same parameters
D
Both B and C are correct
45

An unstructured program is generally ___ to debug than a structured program.

A
easier
B
the same
C
more difficult
D
faster
46

What is the purpose of the function call `clrscr()` used in the examples?

A
To calculate a result
B
To clear the output screen
C
To get input from the user
D
To print to the screen
47

In Example 3 (page 215), `Print_Asterisks()` is an example of a function that?

A
Returns a value and accepts arguments
B
Returns a value but accepts no arguments
C
Returns no value and accepts no arguments
D
Returns no value but accepts arguments
48

The main logic of the `Print_Asterisks` function is built using?

A
if-else statements
B
a switch statement
C
for and while loops
D
recursion
49

Which of the following is NOT a benefit of using functions?

A
Ensuring parallel development
B
Increasing code reusability
C
Making programs harder to understand
D
Simplifying debugging