Learn programming concepts interactively
Before we explore functions, predict: When you call add_numbers(5, 10)
, what happens to the original numbers?
Think of functions as recipes in a kitchen. Each recipe has:
What happens to the original variable when you pass it to a function in C?
Debug these common function mistakes! Can you spot what's wrong?
int multiply(int x, int y) { x * y; }
Functions that return a value must use the 'return' keyword to send the result back to the caller.
int multiply(int x, int y) { return x * y; }
void print_double(int n) { return n * 2; }
Void functions don't return values. Either change to 'int' return type or remove the return statement.
int print_double(int n) { return n * 2; }
📭 Call stack is empty
Execute a function to see the stack in action!
💡 Functions are added to the top of the stack and removed when they finish
🔄 This is how C keeps track of where to return when a function completes
No operations yet
Start by adding or modifying elements