Learn C
#include "functions/function_params.h"

Parameters, Return Values & void in C

#concept

C passes arguments by value — always: the function receives private copies, so callers never change unless you hand over pointers. To modify caller data, pass addresses (void bump(int *p)) and dereference inside; to return multiple results, use several out-pointer parameters plus a status return.

An empty parameter list means unspecified arguments in old style — always write (void) for truly no parameters. main itself has two legal forms: int main(void) and int main(int argc, char *argv[]).

#how it works
1

By value, always

void f(int x) works on a copy — caller data is untouched no matter what the body does.

2

Pointers for out-params

void bump(int *p) { (*p)++; } modifies the caller's variable through its address — C's only by-reference mechanism.

3

(void) means none

int f(void) takes zero arguments; bare int f() means unspecified — always spell (void) in new code.

4

Return status, output via pointers

Return 0/-1 success codes while results flow through pointer parameters — the standard C multi-result pattern.

#example
#include <stdio.h>
 
void bump(int *p) { (*p)++; }
 
int main(void) {
int n = 41;
bump(&n);
printf("%d\n", n);
return 0;
}
Output
42
1bump receives &n — the address, not the value — so *p aliases the caller's n.
2(*p)++ increments through the pointer, rewriting the caller's storage.
342 prints, proving the caller's variable changed via pointer parameter.
#use cases
Modifying caller variables through pointer out-parameters
Multiple results via several pointers plus a status return
Writing (void) signatures so callers can't pass junk
Auditing functions for accidental reliance on by-value copies

Recommended resourcesAffiliate links · may earn us a commission

Recommended for learners

Structured coding coursesVideo courses that pair well with visual practice — pick one language and go deep.Browse courses Pro code editor & AI assistantWrite, debug and explain code faster while you practice the patterns here.Try it free Classic DSA interview booksThe reference books interviewers themselves learned from — great next to the visualizers.See the books

Practice what you learned

Re-implement each visualized algorithm in C yourself — building beats watching.