Function Arguments
Written and reviewed by Gagan Bhardwaj · Senior IT Faculty · 15+ years’ experience
Function Arguments (Parameters)
Function call करते समय जो data pass करते हैं वो arguments कहलाते हैं। Function definition में जो variables उन्हें receive करते हैं वो parameters कहलाते हैं।
C हर argument को value से pass करती है। Integer देने पर integer की copy बनती है। Address देने पर pointer value की copy बनती है; उस pointer को dereference करके caller का object access किया जाता है। Textbooks इसे अक्सर “pass by reference” कहते हैं, लेकिन C में अलग reference-parameter mechanism नहीं है।
Pass by Value
Argument की value की copy pass होती है। Function के अंदर changes original variable को affect नहीं करते।
void double_karo(int n) { // n, argument की COPY है n = n * 2; // केवल local copy बदली printf("Function mein: %d\n", n); } int main() { int x = 5; double_karo(x); // x की copy pass printf("Baad mein: %d\n", x); // x नहीं बदला! }
Pointer Arguments (Address की Copy)
Variable का address argument बनता है। Function को उस address की copy मिलती है और pointer dereference करके वह original object modify कर सकता है। इसे informally pass by reference कहा जाता है।
#include <stdio.h> void swap(int *a, int *b) { // Pointer receive करता है int temp = *a; *a = *b; *b = temp; } int main() { int x = 10, y = 20; printf("Pehle: x=%d, y=%d\n", x, y); swap(&x, &y); // Address pass printf("Baad: x=%d, y=%d\n", x, y); return 0; }
Multiple Values Return करना
void minMax(int arr[], int n, int *mn, int *mx) { *mn = *mx = arr[0]; for(int i=1; i<n; i++) { if(arr[i] < *mn) *mn = arr[i]; if(arr[i] > *mx) *mx = arr[i]; } } int main() { int a[] = {85,32,97,45,11}, mn, mx; minMax(a, 5, &mn, &mx); printf("Min=%d, Max=%d\n", mn, mx); }
सारांश
| Feature | Ordinary value argument | Pointer argument |
|---|---|---|
| क्या pass होता है | Value की copy | Address (pointer) |
| Original बदलता है? | ❌ नहीं | ✅ हाँ |
| Caller syntax | func(x) | func(&x) |
| Function syntax | void f(int n) | void f(int *n) |
| Arrays | Complete array copy नहीं होती | Parameter pointer में adjust होता है |
- C में हर argument value से pass होता है—pointer भी
- Original object modify करने के लिए address pass करके pointer dereference करें
- Array parameter pointer में adjust होता है; length अलग pass करें
- Multiple values "return" करने के लिए pointers use करें
Authoritative संदर्भ
- Function declarations और parameters — cppreference
- Array declarations और parameter adjustment — cppreference
- Function parameters — GNU C Language Manual
References 14 August 2026 को review किए गए। Programs और explanations original teaching material हैं।
अक्सर पूछे जाने वाले प्रश्न (FAQ)
C में function arguments क्या हैं?
add(3, 5) में arguments 3 और 5 add function के अंदर parameters बन जाते हैं।arguments और parameters में क्या अंतर है?
C में call by value क्या है?
क्या C true pass by reference support करती है?
C में function को array कैसे भेजते हैं?
क्या C function value लौटा सकता है?
return statement वह value caller को भेजता है। void declared function कुछ नहीं लौटाता, जबकि int declared एक integer लौटाता है।