Practice high-yield Programming & Software Development MCQs on Function — Part 1 with worked academic solutions for FPSC, PPSC, NTS, NITB, PTS.
Questions
40
Difficulty Level
Exam-Level
Target Exams
FPSC, PPSC, NTS...
Estimated Time
48 mins
Exam-Level FPSC PPSC NTS NITB PTS
Verified for Commission Syllabus • Oct 14, 2026
40
Verified Practice Questions
Interactive test mode with detailed academic worked solutions
Live Progress|0/40 answered
✓0 correct
✗0 wrong
0% score
🎉 Set complete! All 40 questions answered.
Question 1 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression abs(-7.5) in C?
Correct Answer: Option D — Error
Detailed Academic Explanation:
In C, the function abs() is defined in stdlib.h and is used to compute the absolute value of an integer . Passing a floating-point number like -7.5 to abs() is incorrect because abs() expects an int argument. To handle floating-point numbers , C provides a different function called fabs() , which is defined in math.h . Therefore, using abs(-7.5) results in a compile-time error or unexpected behavior because the argument type does not match the function's expected parameter. Option A and B are incorrect because abs() cannot legally process a float. Option C is incorrect because while 7 is the integer part, the input is still a float and would not be accepted by abs() . Hence, the correct answer is Option D: Error .
💡Key Conceptual Anchor:Function
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will happen after compiling and running following code? main() { printf("%p", main); }
Correct Answer: Option C — Some address will be printed.
Detailed Academic Explanation:
Function names are just addresses (just like array names are addresses). main () is also a function. So the address of function main will be printed. %p in printf specifies that the argument is an address. They will be printed as hexadecimal numbers.
💡Key Conceptual Anchor:Function
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Any C program
Correct Answer: Option A — Must contain at least one function.
Detailed Academic Explanation:
Option A: Must contain at least one function. Explanation: In C programming, every valid program must contain at least one function, which is typically the main() function. This function serves as the starting point of execution for the program. Option B: Need not contain any function. Explanation: This option is incorrect because every C program requires at least one function, typically the main() function, to execute. Option C: Needs input data. Explanation: While many programs do require input data, this is not a requirement for the structure of a C program itself. Input data is dependent on the specific requirements of the program being developed. Option D: None of the above. Explanation: This option is incorrect because Option A is correct—every C program must contain at least one function. Conclusion: Option A: Must contain at least one function.
💡Key Conceptual Anchor:Function
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine output: main() { int i = abc(10); printf("%d", --i); } int abc(int i) { return(i++); }
Correct Answer: Option B — 9
Detailed Academic Explanation:
return ( i++ ) it will first return i and then increment. i.e. 10 will be returned.
💡Key Conceptual Anchor:Function
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The default parameter passing mechanism is
Correct Answer: Option A — call by value
Detailed Academic Explanation:
In C programming, the default parameter passing mechanism is call by value . Call by value : In this mechanism, a copy of the actual parameter's value is passed to the function. The function operates on this copy, and changes made to the parameter within the function do not affect the original argument. Call by reference : This is not the default mechanism in C. It involves passing the address of the actual parameter, allowing the function to modify the original value. Call by value result : This mechanism is not used by default in C. It involves passing a copy of the actual parameter and then updating the original variable with the result after the function execution. None of these : This option is incorrect because call by value is indeed the default parameter passing mechanism in C. Thus, Option A: call by value is the correct answer.
💡Key Conceptual Anchor:Function
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of compiling and running this code? main() { char string[] = "Hello World"; display(string); } void display(char *string) { printf("%s", string); }
Correct Answer: Option B — Compilation Error
Detailed Academic Explanation:
Compiler Error : Type mismatch in redeclaration of function display As the function display() is not defined before use, compiler will assume the return type of the function which is int (default return type). But when compiler will see the actual definition of display() , mismatch occurs since the function display() is declared as void . Hence the error.
💡Key Conceptual Anchor:Function
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Determine output: main() { int i = 5; printf("%d%d%d%d%d", i++, i--, ++i, --i, i); }
Correct Answer: Option D — 45545
Detailed Academic Explanation:
The arguments in a function call are pushed into the stack from left to right. The evaluation is by popping out from the stack. and the evaluation is from right to left, hence the result. See the picture below
💡Key Conceptual Anchor:Function
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following program code? main() { static int var = 5; printf("%d ", var--); if(var) main(); }
Correct Answer: Option B — 5 4 3 2 1
Detailed Academic Explanation:
When static storage class is given, it is initialized once. The change in the value of a static variable is retained even between the function calls. Main is also treated like any other ordinary function, which can be called recursively.
💡Key Conceptual Anchor:Function
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be printed when this program is executed? int f(int x) { if(x <= 4) return x; return f(--x); } void main() { printf("%d ", f(7)); }
Correct Answer: Option C — 4
Detailed Academic Explanation:
In this recursive function call the function will return to main caller when the value of x is 4. Hence the output.
💡Key Conceptual Anchor:Function
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The recursive functions are executed in a ...........
Correct Answer: Option C — Last In First Out order
Detailed Academic Explanation:
Because for each function call an entry is created in stack frame( known as Active Record Instance), and are executed in LIFO manner.
💡Key Conceptual Anchor:Function
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The function scanf() returns .........
Correct Answer: Option D — The number of successful read input values.
Detailed Academic Explanation:
According to the prototype, the return type of scanf( ) function is int, that is the number of successful read input values.
💡Key Conceptual Anchor:Function
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is a function primarily used for?
Correct Answer: Option C — Code organization and reusability
Detailed Academic Explanation:
Code organization and reusability is the correct answer to “In C, what is a function primarily used for”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression sqrt(16) in C, assuming proper inclusion of the math library?
Correct Answer: Option A — 4
Detailed Academic Explanation:
4 is the correct answer to “What is the result of the expression sqrt(16) in C, assuming proper inclusion of the math library”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the correct way to declare a function in C that takes no arguments and returns an integer?
Correct Answer: Option C — func()
Detailed Academic Explanation:
func() is the correct answer to “What is the correct way to declare a function in C that takes no arguments and returns an integer”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the 'return' statement in a function?
Correct Answer: Option C — To return a value from the function
Detailed Academic Explanation:
To return a value from the function is the correct answer to “In C, what is the purpose of the 'return' statement in a function”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is not a standard C library function for mathematical operations?
Correct Answer: Option B — rand
Detailed Academic Explanation:
rand is the correct answer to “Which of the following is not a standard C library function for mathematical operations”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the main advantage of using functions in C?
Correct Answer: Option A — Reducing code redundancy and improving code organization
Detailed Academic Explanation:
Reducing code redundancy and improving code organization is the correct answer to “What is the main advantage of using functions in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a function's return type in C if it does not return any value?
Correct Answer: Option B — void
Detailed Academic Explanation:
void is the correct answer to “What is a function's return type in C if it does not return any value”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is a function parameter?
Correct Answer: Option A — A variable declared within a function
Detailed Academic Explanation:
A variable declared within a function is the correct answer to “In C, what is a function parameter”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How is the scope of a local variable defined in C?
Correct Answer: Option A — Limited to the function where it is declared
Detailed Academic Explanation:
Limited to the function where it is declared is the correct answer to “How is the scope of a local variable defined in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a recursive function in C?
Correct Answer: Option A — A function that calls itself
Detailed Academic Explanation:
A function that calls itself is the correct answer to “What is a recursive function in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression abs(-5) in C?
Correct Answer: Option B — 5
Detailed Academic Explanation:
5 is the correct answer to “What is the result of the expression abs(-5) in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is a function definition?
Correct Answer: Option C — A block of code that specifies a function's behavior
Detailed Academic Explanation:
A block of code that specifies a function's behavior is the correct answer to “In C, what is a function definition”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'extern' keyword when declaring a function in C?
Correct Answer: Option A — To specify that the function is not defined in the current file
Detailed Academic Explanation:
To specify that the function is not defined in the current file is the correct answer to “What is the purpose of the 'extern' keyword when declaring a function in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'static' keyword when used with a function in C?
Correct Answer: Option C — To limit the function's visibility to the current source file
Detailed Academic Explanation:
To limit the function's visibility to the current source file is the correct answer to “What is the purpose of the 'static' keyword when used with a function in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the 'void' keyword as a function return type?
Correct Answer: Option A — It specifies that the function doesn't return a value
Detailed Academic Explanation:
It specifies that the function doesn't return a value is the correct answer to “In C, what is the purpose of the 'void' keyword as a function return type”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How do you call a function named myFunction with two arguments in C?
Correct Answer: Option A — myFunction(5, 10)
Detailed Academic Explanation:
myFunction(5, 10) is the correct answer to “How do you call a function named myFunction with two arguments in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is a function's prototype?
Correct Answer: Option B — A declaration that specifies a function's name and parameters
Detailed Academic Explanation:
A declaration that specifies a function's name and parameters is the correct answer to “In C, what is a function's prototype”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression floor(5.7) in C, assuming proper inclusion of the math library?
Correct Answer: Option A — 5
Detailed Academic Explanation:
5 is the correct answer to “What is the result of the expression floor(5.7) in C, assuming proper inclusion of the math library”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the 'inline' keyword when used with a function?
Correct Answer: Option A — To indicate that the function should be inlined by the compiler
Detailed Academic Explanation:
To indicate that the function should be inlined by the compiler is the correct answer to “In C, what is the purpose of the 'inline' keyword when used with a function”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is a function parameter in C?
Correct Answer: Option A — A value passed to a function when it's called
Detailed Academic Explanation:
A value passed to a function when it's called is the correct answer to “What is a function parameter in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression ceil(3.2) in C, assuming proper inclusion of the math library?
Correct Answer: Option B — 4
Detailed Academic Explanation:
4 is the correct answer to “What is the result of the expression ceil(3.2) in C, assuming proper inclusion of the math library”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the 'const' keyword when used with a function parameter?
Correct Answer: Option A — It specifies that the parameter is constant and cannot be modified
Detailed Academic Explanation:
It specifies that the parameter is constant and cannot be modified is the correct answer to “In C, what is the purpose of the 'const' keyword when used with a function parameter”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
How can you declare a function in C that takes a variable number of arguments?
Correct Answer: Option C — Using the '...' notation
Detailed Academic Explanation:
Using the '...' notation is the correct answer to “How can you declare a function in C that takes a variable number of arguments”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is the purpose of the 'recursion' in a function?
Correct Answer: Option D — To call the function itself
Detailed Academic Explanation:
To call the function itself is the correct answer to “In C, what is the purpose of the 'recursion' in a function”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the result of the expression pow(2, 3) in C, assuming proper inclusion of the math library?
Correct Answer: Option C — 8
Detailed Academic Explanation:
8 is the correct answer to “What is the result of the expression pow(2, 3) in C, assuming proper inclusion of the math library”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the purpose of the 'volatile' keyword when used with a function in C?
Correct Answer: Option D — To indicate that the function may change external variables
Detailed Academic Explanation:
To indicate that the function may change external variables is the correct answer to “What is the purpose of the 'volatile' keyword when used with a function in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
In C, what is a function parameter's scope?
Correct Answer: Option A — Limited to the function where it is declared
Detailed Academic Explanation:
Limited to the function where it is declared is the correct answer to “In C, what is a function parameter's scope”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Use of functions
Correct Answer: Option E — All of the above
Detailed Academic Explanation:
All of the above is the correct answer to “Use of functions”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is function?
Correct Answer: Option D — All of the above
Detailed Academic Explanation:
All of the above is the correct answer to “What is function”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
✓Link copied to clipboard
Continue Your Practice
Advance Html — Part 1
Master the next curriculum module with 40 exam-standard MCQs.
💡Examiner's Advisory for Programming & Software Development
In competitive commission exams (FPSC, PPSC, KPPSC, SPSC, CSS, PMS), questions are frequently phrased with distractor options designed to catch rote learners. Whenever you answer an MCQ, read the Detailed Academic Explanation and Conceptual Anchor to understand why the remaining options are incorrect.