Functions & Pass-by-Value — Free C/C++ Tutorial
Learn Functions & Pass-by-Value in C/C++ with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
TL;DR: Learn Functions & Pass-by-Value in C/C++ with a free, beginner-friendly tutorial, examples and practice for Indian students on Syllab.in.
Written & reviewed by the Syllab.in Academic Team (CBSE/NCERT subject experts) · Updated
Functions & Pass-by-Value in C/C++
A function is a named, reusable block of code: it has a return type, a name, a parameter list, and a body. Splitting a program into functions makes it readable and testable. You typically declare a prototype (return type + name + parameters, ending in `;`) before main, and define the body after — or define the whole function before it is used.
C passes arguments by value: the function receives a copy of each argument, so changing a parameter inside the function does NOT change the caller's variable. To let a function modify the caller's variable you pass a pointer (its address) — covered in the pointers topic. This value/reference distinction is central to C.
A function that returns nothing has return type void. Keep functions small and focused — one job each. Good names (isPrime, celsiusToF) make code self-documenting.
Functions & Pass-by-Value — Syntax
int add(int a, int b); // prototype
int add(int a, int b) { return a + b; }
Learn Functions & Pass-by-Value step by step with Syllab's free interactive C/C++ tutorial — runnable code examples, practice exercises and instant AI feedback, all free with no signup. Explore the full C/C++ course →