c / beginner
Snippet
Functions with Parameters
Parameters allow you to pass data into a function. The function can then use these variables to perform its tasks.
snippet.c
1
2
3
void printDouble(int x) {int result = x + x;}
Breakdown
1
void printDouble(int x) {
Defines a function that returns nothing (void) and accepts one integer parameter x.
2
int result = x + x;
Uses the parameter x to perform a local calculation.