Syntax

C Define a Function Syntax

In C, define a function: defines a function with a return type — int add(int a, int b) { return a + b; }

Quick Answer

Syntax
int add(int a, int b) { return a + b; }
CSyntax

Define a Function

Code example
int add(int a, int b) { return a + b; }

Defines a function with a return type.

Learn More

How to define a function in C

  1. Open your C file or editor.
  2. Copy the example, then replace its sample names and values for your code.

C Define a Function Syntax

Use int add(int a, int b) { return a + b; }.

Related Syntax References

Frequently asked questions

What is the C syntax for define a function?

Use this pattern: int add(int a, int b) { return a + b; }

Can I copy this C code example?

Yes. Use Copy code and adapt the example to your program.

Is this C syntax different on Mac or Windows?

No. The language syntax is the same across operating systems.

Official source · How we verify