Skip to main content

Function — Part 2 MCQs with Explanations

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
Question 1 of 40
★ 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.

Question 2 of 40
★ FPSC ★ PPSC

Which of the following is a complete function?

Question 3 of 40
★ FPSC ★ PPSC

Functions have ..........

Question 4 of 40
★ FPSC ★ PPSC

Which of the following function calculates the square of 'x' in C?

Question 5 of 40
★ FPSC ★ PPSC

When a function is recursively called all the automatic variables are stored in a ..........

Question 6 of 40
★ 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; }

Question 7 of 40
★ 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); }

Question 8 of 40
★ 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); }

Question 9 of 40
★ 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; }

Question 10 of 40
★ FPSC ★ PPSC

What would happen if you create a file stdio.h and use #include "stdio.h"?

Question 11 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> int x; void main() { printf("%d", x); }

Question 12 of 40
★ FPSC ★ PPSC

Automatic variables are initialized to . . . . . . . .

Question 13 of 40
★ 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; }

Question 14 of 40
★ FPSC ★ PPSC

Functions can return enumeration constants in C?

Question 15 of 40
★ 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; }

Question 16 of 40
★ 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; }

Question 17 of 40
★ 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; }

Question 18 of 40
★ FPSC ★ PPSC

Which of following is not accepted in C?

Question 19 of 40
★ 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; }

Question 20 of 40
★ FPSC ★ PPSC

Global variables are . . . . . . . .

Question 21 of 40
★ FPSC ★ PPSC

What is the scope of an automatic variable?

Question 22 of 40
★ 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); }

Question 23 of 40
★ FPSC ★ PPSC

If the file name is enclosed in double quotation marks, then . . . . . . . .

Question 24 of 40
★ 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 "); }

Question 25 of 40
★ FPSC ★ PPSC

Which of the following storage class supports char data type?

Question 26 of 40
★ FPSC ★ PPSC

register keyword mandates compiler to place it in machine register.

Question 27 of 40
★ 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 }

Question 28 of 40
★ FPSC ★ PPSC

Functions have static qualifier for its declaration by default.

Question 29 of 40
★ FPSC ★ PPSC

Can we use a function as a parameter of another function? [Eg: void wow(int func())].

Question 30 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> void main() { static int x; if (x++ < 2) main(); }

Question 31 of 40
★ FPSC ★ PPSC

Assignment statements assigning value to local static variables are executed only once.

Question 32 of 40
★ FPSC ★ PPSC

The #else directive is used for . . . . . . . .

Question 33 of 40
★ 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 ); }

Question 34 of 40
★ FPSC ★ PPSC

Conditional inclusion can be used for . . . . . . . .

Question 35 of 40
★ FPSC ★ PPSC

What will be the output of the following C code? #include <stdio.h> void main() { { int x = 8; } printf("%d", x); }

Question 36 of 40
★ FPSC ★ PPSC

Comment on the output of the following C code. #include <stdio.h> #define var 20); int main() { printf("%d\n", var }

Question 37 of 40
★ 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; } }

Question 38 of 40
★ 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; }

Question 39 of 40
★ FPSC ★ PPSC

C preprocessor is conceptually the first step during compilation.

Question 40 of 40
★ 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); }

✓ Link copied to clipboard
Continue Your Practice

Advance Html — Part 1

Master the next curriculum module with 40 exam-standard MCQs.

Next Practice Set →

💡 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.

More Modules in Programming & Software Development

View All →
📚

Study Guides

Topic summaries and syllabus breakdown

Explore Guides →
🎯

Complete Library

Search through 78,000+ verified MCQs

Browse Library →
📱

Mobile App

Offline mock tests and instant bookmarks

Get Mobile App →