β˜‘ MCQ PRACTICE

Programming for Problem Solving Unit 3

Practice objective questions for quick revision and examination preparation. Try answering each question before revealing the answer.

πŸ“š Programming for Problem Solving
πŸ“– Unit 3
🎯 MCQs

Programming for Problem Solving - Unit-3

1
What is the primary goal of Top-Down Design?
ATo write the entire program in one function.
BTo start coding immediately without planning.
CTo break a complex problem into smaller, more manageable subproblems.
DTo focus on optimizing the code for speed from the beginning.
Correct Answerc
2
A Structure Chart in top-down design is used to:
ADisplay the values of variables during execution.
BShow the hierarchical relationship between program modules (functions).
CList all the library functions used in the program.
DDraw the flow of data in memory.
Correct Answerb
3
Which of the following is a valid example of a standard Library Function?
AcalculateAverage()
Bmy_print()
Cscanf()
DgetUserInput()
Correct Answerc
4
A function that performs a task but does not return a value should be declared with what return type?
Aint
Bdouble
Cchar
Dvoid
Correct Answerd
5
The & operator in C, when used with a variable, is known as the:
AIndirection operator
BAddress-of operator
CMultiplication operator
DValue-of operator
Correct Answerb
6
What is the purpose of an input argument to a function?
ATo allow the function to modify the original argument's value.
BTo send a value from the caller into the function for processing.
CTo return multiple values from the function.
DTo point to a memory location.
Correct Answerb
7
Consider the code: int y = 5; int *ptr = &y;. What is the value of *ptr?
AThe memory address of y
BThe value 5
CThe memory address of ptr
DAn undefined value
Correct Answerb
8
What is the key characteristic of a function with an output parameter?
AIt uses a return statement to send back a value.
BIt takes one or more arguments as pointers, allowing it to modify the variables in the caller's scope.
CIt can only be called once from the main function.
DIt does not accept any arguments.
Correct Answerb
9
In the function call swap(&num1, &num2);, what is the purpose of the & operator?
AIt performs a logical AND operation.
BIt dereferences the pointers num1 and num2.
CIt passes the addresses of num1 and num2 so the swap function can modify them.
DIt ensures the values of num1 and num2 are not changed.
Correct Answerc
10
The scope of a local variable declared inside a function is:
AThe entire program.
BOnly from the point of declaration to the end of that function's block.
COnly inside the main function.
DGlobal and can be accessed by any function.
Correct Answerb
11
Which of the following function prototypes correctly defines a function with an output parameter for an integer?
Avoid process(int data);
Bint process(int *data);
Cvoid process(int *data);
Dvoid process(int &data);
Correct Answerc
12
When a function with an output parameter is called multiple times, what happens?
AThe function's code is duplicated for each call.
BThe same function code is executed, but it can manipulate different memory locations each time it is called.
CIt can only be used with global variables.
DIt becomes an inline function automatically.
Correct Answerb
13
What is a potential risk of using an uninitialized pointer?
AIt will always point to zero.
BIt may cause a segmentation fault or access unintended memory locations.
CIt automatically initializes to NULL.
DThe program will compile but run slowly.
Correct Answerb
14
Why is it generally considered bad practice to use global variables extensively to share data between functions?
AThey make the program faster.
BThey improve the modularity and reusability of functions.
CThey can lead to code that is difficult to debug and maintain because any function can change them.
DThey have a very limited scope.
Correct Answerc
15
In top-down design, what is the relationship between a function's "caller" and "called" function as shown in a structure chart?
AThe called function is a parent of the caller.
BThe caller is a subordinate module to the called function.
CThe caller is a higher-level module that delegates a task to the called (lower-level) function.
DThey are unrelated.
Correct Answerc
16
What is the primary conceptual difference between a function's return statement and an output parameter?
AThere is no difference; they are syntactically the same.
BA return statement can send back one value, while output parameters can be used to return multiple values.
COutput parameters are used for input, and return is used for output.
DA return statement modifies the argument directly.
Correct Answerb
17
What will happen if you pass a NULL pointer to a function that then tries to dereference it (e.g., *ptr = 10;)?
AThe value 10 will be stored at memory address 0.
BThe program will compile and run without any issues.
CIt will typically result in a runtime error, such as a segmentation fault.
DThe pointer will automatically be assigned a new address.
Correct Answerc
18
The keyword used to define a function that does not return any value in c with values?
Aint
Bvoid
Cnull
Dstatic
Correct Answerb
19
Which of the following is correct way to declare and initialize an array in c with values? {10,20,30}
Aint arr[]={10,20,30};
Bint arr[2]={10,20,30};
Carr={10,20,30};
Dint arr={10,20,30};
Correct AnswerAnswer:A
20
Which of the following storage class variable will store in CPU register?
Aauto
Bstatic
Cregister
Dextern
Correct Answerc
21
Which of the following statement is correct?
AFunction avoids rewrite same code in multiple times.
BFunction breakdown complex problem to smaller parts.
CFunctions provide easy debugging.
DAll the above.
Correct Answerd
22
Function prototype is also called as
AFunction definition.
BFunction declaration.
CFunction call.
DNone of the above.
Correct Answerb
23
Which of the following statement is correct?
AReturn statement terminate function execution.
BReturn statement execute anything after it.
CReturn statement is a result of function.
DAll the above
Correct Answerd
24
Which of the following statement is not correct?
AWhile writing a function actual parameters must be equal to formal parameters.
BWe can call a function multiple times.
CFunction won’t provide limited access to local variable.
DFunction declaration is optional while writing a function.
Correct AnswerC
25
Which of the following statement is not correct
AIn call by value method, different memory will be allocated to actual parameters and formal parameters.
BIn call by value method, if we do modification in formal parameters that change actual parameters.
CIn call by value method, we modification in formal parameters that won’t change actual parameters.
DNone of the above.
Correct AnswerB
26
Which of the following statement is correct?
AFunction declaration is optional while writing a function.
BFunction call must be inside main ().
CWe can write function anywhere in a program.
DAll the above.
Correct AnswerD
27
Which of the following statement is not correct?
AParameters which are passed to function definition is called formal parameters.
BParameters which are passed to function call is known as actual parameters.
CParameter which are passed to function definition is known as actual parameters.
DParameter which are passed to function definition is known as formal arguments.
Correct AnswerC
28
Which of the following statement is not correct ?
AThe default value of auto storage class variable is 0.
BThe scope of auto storage class variable is local.
CThe life of auto storage class variable is with in function or block
DNone of the above
Correct AnswerA
29
Which of the following statement is correct?
AThe default value of static storage class variable is garbage value.
BThe static storage class variable stored in CPU RAM.
CThe scope of static variable is global.
DNone of the above.
Correct AnswerD
30
Which of the following statement is correct?
Aextern storage class variable stored in RAM.
BRegister storage class variable stored in CPU register.
CAuto storage class variable stored in RAM.
DAll the above.
Correct AnswerD
31
The value passed to a function when it is called is known as a(n)_____.
AArgument or actual parameter
BVariable
CIdentifier
DFunction name
Correct AnswerArgument or actual parameter
32
The dereference operator (*) in C is used to ______
AGet the address of a variable
BAccess the value stored at the address pointed by a pointer
CDeclare a variable
DMultiply two numbers
Correct AnswerAccess the value stored at the address pointed by a pointer
33
A function is a:
AA set of statements performing a specific task
BA preprocessor directive
CA variable
DA keyword
Correct AnswerA set of statements performing a specific task
34
If int *p; and int x = 20; what does p = &x; do?
AStores value 20 in pointer
BStores address of x in p
CCreates a new variable
DGives an error
Correct AnswerStores address of x in p
35
In C, how are function arguments passed by default?
Aby value
Bby reference
Cby pointer
Dby address
Correct Answerby value
36
Which of the following statements about functions in C is true?
AA function in C can return more than one value.
BEvery C program must have at least one function named main().
CA function must always take at least one parameter.
DFunctions in C cannot call other functions.
Correct AnswerEvery C program must have at least one function named main().
37
Arguments passed to a function in C language are called ___ arguments.
AFormal arguments
BActual Arguments
CDefinite Arguments
DIdeal Arguments
Correct AnswerActual Arguments
38
Which keyword is used to transfer control back from a function to the calling Function?
Agoto
Breturn
Cswitch
Dexit
Correct Answerreturn

Fill in the Blanks

39A function declaration also called as_____________
Correct Answerprototype
40A parameter is known as______________. Which are passed to function call.
Correct AnswerArgument or Actual parameter or Actual argument
41A parameter is known as ________ which is passed to function definition.
Correct Answerformal parameter
42Pointer is variable which stores___________ of variable.
Correct AnswerAddress/reference
43In ___________method different memory will be allocated to actual parameter and formal parameters.
Correct AnswerCall by value
44In____________ Method similar memory will be allocated to actual parameters and formal parameters.
Correct AnswerCall by reference
45___________ block statements to perform specific task.
Correct AnswerFunction
46In________ method if we do modification in formal parameters that does not impact in actual parameters.
Correct AnswerCall by value
47In____________ method if we do modification in formal parameters that will change in actual parameters.
Correct Answercall by reference
48____________ Method address of actual parameter is copy into formal parameter.
Correct Answercall by reference
49__________is default return type of function.
Correct Answerint
50In pointers "*" is called ______________.
Correct Answerindirection operator/Dereferencing operator
51_____ is the default value of auto storage class?
Correct AnswerGarbage value
52Default value of static storage class variable is ________.
Correct Answer0
53_______storage class variable is available at multiple source files.
Correct Answerextern
54_______ storage class variable is stored is CPU register.
Correct Answerregister
55_______ storage class initialize only time and exists till end of the program.
Correct Answerstatic
56_______ storage class variable scope is global.
Correct Answerextern
57Array index position starts from __________.
Correct Answerzero
58A function declaration is also known as a function ________________________
Correct Answerprototype
59The part of a function where code is written is called the __________ of the function.
Correct AnswerFunction defination
60A ___________________ is a block of code that performs specific task.
Correct AnswerFuntion
61The process of dividing a program into smaller modules or functions is called __________.
Correct Answermodularity
62The variable that receive values from calling functions are called______________
Correct Answerfunction defination
63In C, function can be categorized as library functions and ___________function.
Correct Answeruser defined functions
64A function that does not return any value must have the return type___________.
Correct Answervoid
65Variables within a block have global scope.(T/F)____
Correct AnswerFalse
66The function that returns square root of a given number is _______
Correct Answersqrt(x);
67scanf () is a _________ function in C program.
Correct Answerinput
68The syntax for function call is ______________.
Correct Answerfunction_name(argument)
69Default value of Register variable is = ___________________
Correct AnswerGarbage value
70How many values can a C Function return at a time = ___________________
Correct Answerone value
71A ___________________ is a block of code that performs specific task.
Correct Answerfunction
← Back to All MCQs