Thuta Learning
IntermediateProgrammingbeginner

Function Parameters

Relax. We'll talk through this in plain words — no textbook voice.

A parameter is how you pass data into a function. If you want a function to be reusable, it's better to use parameters instead of hard-coded values.

c
#include <stdio.h>

void greet(char name[], int age) {
  printf("Hello %s, age %d
", name, age);
}

int main() {
  greet("Sai", 20);
  greet("Nandar", 22);
  return 0;
}

greet() function accepts two parameters — name and age. Passing different values when you call the function produces different output.

You should see
Hello Sai, age 20 Hello Nandar, age 22

Info

Make sure the argument types you pass match the parameter types.

Easy traps

  • Calling it as greet(20, "Sai") with the arguments in the wrong order no longer matches the function signature.
Function Parameters | Thuta Learning