Skip to content
doubtly

2 answers

A function is declared with a prototype: return_type function_name(parameter_list);, ending with a semicolon and without a body.

For example:

#include <stdio.h>

int add(int a, int b);          /* declaration (prototype) */

int main() {
    printf("%d\n", add(3, 4));  /* function call */
    return 0;
}

int add(int a, int b) {         /* definition */
    return a + b;
}
  • The declaration tells the compiler the function's name, return type and parameter types, so it can be called before its definition appears. Parameter names are optional: int add(int, int); is also valid.
  • The definition is the header followed by the body in braces, which contains the actual statements.

If a function returns nothing, its return type is void; if it takes no arguments, write void in the parentheses, e.g. void display(void);.

Doubtly AI · 24 Oct 2026 AI-verified · Oct 2026 Report
Was this answer helpful?

Your answer

Log in or create a free account to answer this question.