---
title: "Merits of functions; actual vs formal parameters"
subject: "Computer Programming"
chapter: 6
key: "semester_1/computer_programming:udf-merits-demerits-parameters"
source: https://www.bctengineer.com/q/semester_1/computer_programming/udf-merits-demerits-parameters
site: BCT Engineering
---

# Merits of functions; actual vs formal parameters

Computer Programming · Chapter 6: User-Defined Functions

- Asked in: 2068 Shrawan, 3+2+3 marks
- Video: [Actual & Formal Parameters](https://www.youtube.com/watch?v=9TdSJtzucAU) — Jaya's Networks
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/udf-merits-demerits-parameters
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-6

## Question

Why programmers prefer using user defined functions? What is merits and demerits of using functions in program? Differentiate actual and formal parameters used in functions.

## Short answer

Programmers use user-defined functions for modularity, code reuse, readability, and easier testing. Merits include maintainability and teamwork; demerits are extra call overhead and stack usage. Actual parameters appear in the call (e.g., a, b); formal parameters appear in the definition header (e.g., p, q) and receive copies of the actual values.

## Answer

#### Why programmers prefer user-defined functions
- They divide a large program into smaller manageable parts.
- Code written once can be reused in many places and programs.
- They shorten the program, and make it readable.
- Testing and debugging are easier, as each function is checked separately.
- They allow several programmers to work on one project.

#### Merits and demerits

| Merits | Demerits |
|---|---|
| Modularity and reusability | A function call takes extra time and memory (stack) |
| Shorter and clearer code | Too many functions make flow hard to follow |
| Easy maintenance and debugging | Passing many arguments is complex |
| Teamwork is possible | Needs correct prototypes, type matching and return values |
| Same logic used again and again | Recursive functions can use up the stack |

#### Actual versus formal parameters

| Actual parameters | Formal parameters |
|---|---|
| Values/variables written in the function **call** | Variables written in the function **definition** header |
| Belong to the calling function | Belong to the called function |
| Can be constants, variables or expressions | Must be variables with a declared type |
| Their values are sent to the function | They receive copies of the values |

```c
#include <stdio.h>
int add(int p, int q)        /* p and q are formal parameters */
{
    return p + q;
}
int main(void)
{
    int a = 4, b = 6;
    printf("%d\n", add(a, b));   /* a and b are actual parameters */
    return 0;
}
```
Output: `10`. Here `a` and `b` are actual parameters; `p` and `q` are formal parameters.

## Check yourself

The answer's key points as multiple-choice questions, with the correct option and why.

1. Actual parameters?
   A. In header
   B. Types
   C. Values in function call
   D. Locals
   Answer: C. Call. (Key point: Actual)

2. Formal parameters?
   A. Constants
   B. Calls
   C. Globals
   D. Variables in definition header
   Answer: D. Header. (Key point: Formal)

3. A demerit?
   A. Call takes extra time and stack memory
   B. More readable
   C. Reuse
   D. Teamwork
   Answer: A. Overhead. (Key point: Demerit)

4. In add(a,b) call with p,q?
   A. a,b formal
   B. a,b actual; p,q formal
   C. All actual
   D. All formal
   Answer: B. Call vs definition. (Key point: Example)

## Related in Computer Programming

- [Significance of user defined functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Asignificance-user-defined-functions) — Computer Programming, chapter 6
- [Switch versus user defined function](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aswitch-vs-user-function) — Computer Programming, chapter 5
- [I/O functions used with data files](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Afile-io-functions) — Computer Programming, chapter 10, asked 2×
- [Declaration vs definition; C program structure](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Adeclaration-definition-structure-of-c) — Computer Programming, chapter 3
- [Advantages of using functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Aadvantages-of-functions) — Computer Programming, chapter 6
- [Reverse a string using functions](https://www.bctengineer.com/question.md?key=semester_1%2Fcomputer_programming%3Astring-reverse-with-count-function) — Computer Programming, chapter 7, asked 2×

## Related in other subjects

- [Forward vs reverse engineering merits and demerits](https://www.bctengineer.com/question.md?key=semester_6%2Fobject_oriented_analysis_and_design%3Aforward-reverse-engineering-merits) — Object Oriented Analysis and Design, chapter 4, asked 3×
- [Merits and demerits of active vs passive filters](https://www.bctengineer.com/question.md?key=semester_5%2Ffilter_design%3Aactive-passive-merits-demerits) — Filter Design, chapter 6
- [Convert user-defined type to basic type](https://www.bctengineer.com/question.md?key=semester_3%2Fobject_oriented_programming%3Auser-to-basic-conversion) — Object Oriented Programming, chapter 5
- [Three pipe materials with merits/demerits](https://www.bctengineer.com/question.md?key=semester_5%2Fwater_supply_engineering%3Apipe-materials-merits-demerits) — Water Supply Engineering, chapter 8, asked 4×
