Practice high-yield Programming & Software Development MCQs on Function — Part 2 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
Pick the correct statements. I. The body of a function should have only one return statement. II. The body of a function may have many return statements. III. A function can return only one value to the calling environment. IV. If return statement is omitted, then the function does its job but returns no value to the calling environment.
Correct Answer: Option C — II and III
Detailed Academic Explanation:
II and III is the correct answer to “Pick the correct statements. I. The body of a function should have only one return statement. II. The body of a function may have many return statements. III. A function can return only one value to the calling environment. IV. If return statement is omitted, then the function does its job but returns no value to the calling environment.”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 2 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following is a complete function?
Correct Answer: Option B — int funct(int x) { return x=x+1; }
Detailed Academic Explanation:
int funct(int x) { return x=x+1; } is the correct answer to “Which of the following is a complete function”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 3 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Functions have ..........
Correct Answer: Option C — File scope
Detailed Academic Explanation:
File scope is the correct answer to “Functions have ..........”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 4 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following function calculates the square of 'x' in C?
Correct Answer: Option C — pow(x, 2)
Detailed Academic Explanation:
pow(x, 2) is the correct answer to “Which of the following function calculates the square of 'x' in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 5 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
When a function is recursively called all the automatic variables are stored in a ..........
Correct Answer: Option A — Stack
Detailed Academic Explanation:
Stack is the correct answer to “When a function is recursively called all the automatic variables are stored in a ..........”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 6 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> #define foo(x, y) #x #y int main() { printf("%s\n", foo(k, l)); return 0; }
Correct Answer: Option A — kl
Detailed Academic Explanation:
kl is the correct answer to “What will be the output of the following C code? #include <stdio.h> #define foo(x, y) #x #y int main() { printf("%s\n", foo(k, l)); return 0; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 7 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> double var = 8; int main() { int var = 5; printf("%d", var); }
Correct Answer: Option A — 5
Detailed Academic Explanation:
5 is the correct answer to “What will be the output of the following C code? #include <stdio.h> double var = 8; int main() { int var = 5; printf("%d", var); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 8 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int x = 5; void main() { int x = 3; printf("%d", x); { x = 4; } printf("%d", x); }
Correct Answer: Option D — 3 4
Detailed Academic Explanation:
3 4 is the correct answer to “What will be the output of the following C code? #include <stdio.h> int x = 5; void main() { int x = 3; printf("%d", x); { x = 4; } printf("%d", x); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 9 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which part of the program address space is p stored in the following C code? #include <stdio.h> int *p = NULL; int main() { int i = 0; p = &i; return 0; }
Correct Answer: Option B — Data segment
Detailed Academic Explanation:
Data segment is the correct answer to “Which part of the program address space is p stored in the following C code? #include <stdio.h> int *p = NULL; int main() { int i = 0; p = &i; return 0; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 10 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What would happen if you create a file stdio.h and use #include "stdio.h"?
Correct Answer: Option B — The user-defined library file will be selected
Detailed Academic Explanation:
The user-defined library file will be selected is the correct answer to “What would happen if you create a file stdio.h and use #include "stdio.h"”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 11 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int x; void main() { printf("%d", x); }
Correct Answer: Option C — 0
Detailed Academic Explanation:
0 is the correct answer to “What will be the output of the following C code? #include <stdio.h> int x; void main() { printf("%d", x); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 12 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Automatic variables are initialized to . . . . . . . .
Correct Answer: Option B — Junk value
Detailed Academic Explanation:
Junk value is the correct answer to “Automatic variables are initialized to . . . . . . . .”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 13 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> #define MIN 0 #if defined(MIN) + defined(MAX) #define MAX 10 #endif int main() { printf("%d %d\n", MAX, MIN); return 0; }
Correct Answer: Option A — 10 0
Detailed Academic Explanation:
10 0 is the correct answer to “What will be the output of the following C code? #include <stdio.h> #define MIN 0 #if defined(MIN) + defined(MAX) #define MAX 10 #endif int main() { printf("%d %d\n", MAX, MIN); return 0; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 14 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Functions can return enumeration constants in C?
Correct Answer: Option A — true
Detailed Academic Explanation:
true is the correct answer to “Functions can return enumeration constants in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 15 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int foo(int, int); #define foo(x, y) x / y + x int main() { int i = -6, j = 3; printf("%d ",foo(i + j, 3)); #undef foo printf("%d\n",foo(i + j, 3)); } int foo(int x, int y) { return x / y + x; }
Correct Answer: Option A — -8 -4
Detailed Academic Explanation:
-8 -4 is the correct answer to “What will be the output of the following C code? #include <stdio.h> int foo(int, int); #define foo(x, y) x / y + x int main() { int i = -6, j = 3; printf("%d ",foo(i + j, 3)); #undef foo printf("%d\n",foo(i + j, 3)); } int foo(int x, int y) { return x / y + x; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 16 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int x; void main() { m(); printf("%d", x); } void m() { x = 4; }
Correct Answer: Option B — 4
Detailed Academic Explanation:
4 is the correct answer to “What will be the output of the following C code? #include <stdio.h> int x; void main() { m(); printf("%d", x); } void m() { x = 4; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 17 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int foo(); int main() { int i = foo(); } foo() { printf("2 "); return 2; }
Correct Answer: Option A — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following C code? #include <stdio.h> int foo(); int main() { int i = foo(); } foo() { printf("2 "); return 2; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 18 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of following is not accepted in C?
Correct Answer: Option C — static static int a; //a static variable prefixed with static
Detailed Academic Explanation:
static static int a; //a static variable prefixed with static is the correct answer to “Which of following is not accepted in C”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 19 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int *m(); void main() { int k = m(); printf("%d", k); } int *m() { int a[2] = {5, 8}; return a; }
Correct Answer: Option D — Varies
Detailed Academic Explanation:
Varies is the correct answer to “What will be the output of the following C code? #include <stdio.h> int *m(); void main() { int k = m(); printf("%d", k); } int *m() { int a[2] = {5, 8}; return a; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 20 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Global variables are . . . . . . . .
Correct Answer: Option B — External
Detailed Academic Explanation:
External is the correct answer to “Global variables are . . . . . . . .”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 21 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What is the scope of an automatic variable?
Correct Answer: Option D — Within the block it appears & Within the blocks of the block it appears
Detailed Academic Explanation:
Within the block it appears & Within the blocks of the block it appears is the correct answer to “What is the scope of an automatic variable”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 22 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code having void return-type function? #include <stdio.h> void foo() { return 1; } void main() { int x = 0; x = foo(); printf("%d", x); }
Correct Answer: Option D — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “What will be the output of the following C code having void return-type function? #include <stdio.h> void foo() { return 1; } void main() { int x = 0; x = foo(); printf("%d", x); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 23 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
If the file name is enclosed in double quotation marks, then . . . . . . . .
Correct Answer: Option A — The preprocessor treats it as a user-defined file
Detailed Academic Explanation:
The preprocessor treats it as a user-defined file is the correct answer to “If the file name is enclosed in double quotation marks, then . . . . . . . .”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 24 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> void foo(); int main() { void foo(); foo(); return 0; } void foo() { printf("2 "); }
Correct Answer: Option B — 2
Detailed Academic Explanation:
2 is the correct answer to “What will be the output of the following C code? #include <stdio.h> void foo(); int main() { void foo(); foo(); return 0; } void foo() { printf("2 "); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 25 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Which of the following storage class supports char data type?
Correct Answer: Option D — all of the mentioned
Detailed Academic Explanation:
all of the mentioned is the correct answer to “Which of the following storage class supports char data type”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 26 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
register keyword mandates compiler to place it in machine register.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “register keyword mandates compiler to place it in machine register.”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 27 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> #define SYSTEM 20 int main() { int a = 20; #if SYSTEM == a printf("HELLO "); #endif #if SYSTEM == 20 printf("WORLD\n"); #endif }
Correct Answer: Option B — WORLD
Detailed Academic Explanation:
WORLD is the correct answer to “What will be the output of the following C code? #include <stdio.h> #define SYSTEM 20 int main() { int a = 20; #if SYSTEM == a printf("HELLO "); #endif #if SYSTEM == 20 printf("WORLD\n"); #endif }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 28 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Functions have static qualifier for its declaration by default.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “Functions have static qualifier for its declaration by default.”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 29 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Can we use a function as a parameter of another function? [Eg: void wow(int func())].
Correct Answer: Option C — No, C does not support it
Detailed Academic Explanation:
No, C does not support it is the correct answer to “Can we use a function as a parameter of another function? [Eg: void wow(int func())].”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 30 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> void main() { static int x; if (x++ < 2) main(); }
Correct Answer: Option D — main is called twice
Detailed Academic Explanation:
main is called twice is the correct answer to “What will be the output of the following C code? #include <stdio.h> void main() { static int x; if (x++ < 2) main(); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 31 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Assignment statements assigning value to local static variables are executed only once.
Correct Answer: Option B — False
Detailed Academic Explanation:
False is the correct answer to “Assignment statements assigning value to local static variables are executed only once.”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 32 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
The #else directive is used for . . . . . . . .
Correct Answer: Option A — Conditionally include source text if the previous #if, #ifdef, #ifndef, or #elif test fails
Detailed Academic Explanation:
Conditionally include source text if the previous #if, #ifdef, #ifndef, or #elif test fails is the correct answer to “The #else directive is used for . . . . . . . .”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 33 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> void foo(auto int i); int main() { foo(10); } void foo(auto int i) { printf("%d\n", i ); }
Correct Answer: Option B — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “What will be the output of the following C code? #include <stdio.h> void foo(auto int i); int main() { foo(10); } void foo(auto int i) { printf("%d\n", i ); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 34 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Conditional inclusion can be used for . . . . . . . .
Correct Answer: Option D — All of the mentioned
Detailed Academic Explanation:
All of the mentioned is the correct answer to “Conditional inclusion can be used for . . . . . . . .”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 35 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> void main() { { int x = 8; } printf("%d", x); }
Correct Answer: Option D — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “What will be the output of the following C code? #include <stdio.h> void main() { { int x = 8; } printf("%d", x); }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 36 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
Comment on the output of the following C code. #include <stdio.h> #define var 20); int main() { printf("%d\n", var }
Correct Answer: Option A — No errors, it will show the output 20
Detailed Academic Explanation:
No errors, it will show the output 20 is the correct answer to “Comment on the output of the following C code. #include <stdio.h> #define var 20); int main() { printf("%d\n", var }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 37 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the sequence of allocation and deletion of variables in the following C code? #include <stdio.h> int main() { int a; { int b; } }
Correct Answer: Option B — a->b, b->a
Detailed Academic Explanation:
a->b, b->a is the correct answer to “What will be the sequence of allocation and deletion of variables in the following C code? #include <stdio.h> int main() { int a; { int b; } }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 38 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> enum m{JAN, FEB, MAR}; enum m foo(); int main() { enum m i = foo(); printf("%d\n", i); } int foo() { return JAN; }
Correct Answer: Option A — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “What will be the output of the following C code? #include <stdio.h> enum m{JAN, FEB, MAR}; enum m foo(); int main() { enum m i = foo(); printf("%d\n", i); } int foo() { return JAN; }”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 39 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
C preprocessor is conceptually the first step during compilation.
Correct Answer: Option A — True
Detailed Academic Explanation:
True is the correct answer to “C preprocessor is conceptually the first step during compilation.”. This question is standard in competitive examination syllabi for Function.
💡Key Conceptual Anchor:Function
Question 40 of 40
★ FPSC
★ PPSC
★ FPSC
★ PPSC
What will be the output of the following C code? #include <stdio.h> int main() { register const int i = 10; i = 11; printf("%d\n", i); }
Correct Answer: Option B — Compile time error
Detailed Academic Explanation:
Compile time error is the correct answer to “What will be the output of the following C code? #include <stdio.h> int main() { register const int i = 10; i = 11; printf("%d\n", i); }”. 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.