---
title: "Function prototyping"
subject: "Computer Programming"
chapter: 6
key: "semester_1/computer_programming:function-prototyping"
source: https://www.bctengineer.com/q/semester_1/computer_programming/function-prototyping
site: BCT Engineering
---

# Function prototyping

Computer Programming · Chapter 6: User-Defined Functions

- Asked in: 2072 Kartik, 2 marks
- Video: [What is a function prototype in C](https://www.youtube.com/watch?v=jxW7iwCtBZk) — Jacob Sorber
- Answer checked by Claude Opus 5.5 (high effort) on 2026-10-14
- Page: https://www.bctengineer.com/q/semester_1/computer_programming/function-prototyping
- Whole chapter: https://www.bctengineer.com/md/semester_1/computer_programming/chapter-6

## Question

What is the meaning of function prototyping?

## Short answer

A function prototype declares return type, name, and parameter types before use (e.g., float avg(int, int);). It enables compiler argument checking and allows calling functions defined later.

## Answer

**Function prototyping** means declaring a function before it is used, to tell the compiler its name, return type and the number and types of its parameters. The prototype ends with a semicolon and has no body.

**Syntax:** `return_type function_name(parameter_types);`

For example `float average(int, int);`

Use:
- lets the compiler check each call for the correct number and types of arguments;
- allows calling a function that is defined after `main()`;
- prevents wrong return-type assumptions.

```c
#include <stdio.h>
float average(int, int);           /* function prototype */
int main(void)
{
    printf("Average = %.1f\n", average(7, 10));
    return 0;
}
float average(int a, int b)
{
    return (a + b) / 2.0f;
}
```
Output:
```text
Average = 8.5
```

## Check yourself

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

1. Prototype is?
   A. Body
   B. Loop
   C. Declaration of name, return type, params before use
   D. Header file
   Answer: C. Declaration. (Key point: Meaning)

2. Ends with?
   A. Brace
   B. Colon
   C. Nothing
   D. Semicolon, no body
   Answer: D. Ends with ;. (Key point: Syntax)

3. Benefit?
   A. Compiler checks args count and types
   B. Faster
   C. Less memory
   D. Recursion
   Answer: A. Type checking. (Key point: Use)

## Related in other subjects

- [FT of DC; meaning of ESD and PSD](https://www.bctengineer.com/question.md?key=semester_4%2Fsignals_and_systems%3Aft-dc-esd-psd) — Signals and Systems, chapter 3
- [Interpret: verbal communication across cultures](https://www.bctengineer.com/question.md?key=semester_5%2Fcommunication_english%3Ainterpret-verbal-communication-cultures) — Communication English, chapter 1
- [Flexural bond stress and Ld proof](https://www.bctengineer.com/question.md?key=semester_7%2Fdesign_of_rcc_structure%3Aflexural-bond-stress-and-ld-proof) — Design of RCC Structure, chapter 6
