📌 What are Parameters?

Parameters are variables listed in the function definition that act as input to the function.

They allow you to pass data into a function when you call it.


✅ Syntax:


returnType functionName(type1 param1, type2 param2, ...) {
    // function body
}

Example:


int add(int a, int b) {
    return a + b;
}

Yahan a aur b parameters hain.


🔄 How Parameters Work?


🔹 Example:


#include<iostream>
using namespace std;

void greet(string name) {
    cout << "Hello, " << name << "!" << endl;
}

int main() {
    greet("Nikhil");
    greet("Ravi");
    return 0;
}

Output:


Hello, Nikhil!
Hello, Ravi!


🧠 Types of Parameters:

Type Description
Value Parameters Actual value copied to function
Reference Parameters Pass memory address, original variable affected
Default Parameters Parameters with default values