Notes in Hindi

Meaning of Function Arguments in Hindi

/ BCA / Programming with C and CPP

Function Arguments in C Explained in Hindi

Meaning of Function Arguments in Hindi

C language में जब हम किसी function को बनाते हैं, तो हमें कभी-कभी उसके अंदर कुछ values भेजनी पड़ती हैं ताकि वह उन्हीं values पर काम करे। इन्हीं values को हम **Function Arguments** या **Function Parameters** कहते हैं।

Function arguments वो variables होते हैं जो किसी function को call करते समय भेजे जाते हैं, ताकि function उनके आधार पर कोई कार्य (processing) कर सके। जब हम function को call करते हैं तो जो value भेजते हैं उसे **Actual Argument** कहते हैं और function definition में जो variables होते हैं, उन्हें **Formal Arguments** कहा जाता है।

Why are Function Arguments used?

  • Function को flexible और reusable बनाने के लिए।
  • किसी विशेष value पर calculation करने के लिए।
  • Function को अलग-अलग input देने के लिए।

Example:

नीचे एक simple example देखिए जहाँ एक function दो numbers को जोड़ता है:

#include <stdio.h> void add(int a, int b) { printf("Sum is: %d", a + b); } int main() { add(5, 10); // 5 और 10 actual arguments हैं return 0; }

ऊपर दिए गए program में a और b function arguments हैं जो कि add() function को दिए गए हैं।

Types of Function Arguments in C in Hindi

C में function arguments को दो मुख्य तरीकों से pass किया जा सकता है:

1. Call by Value

  • इस method में actual value को copy करके function को भेजा जाता है।
  • Function के अंदर की गई changes का असर main function पर नहीं होता।

Example:

#include <stdio.h> void change(int x) { x = x + 10; printf("Inside function: %d\n", x); } int main() { int a = 5; change(a); printf("Outside function: %d", a); return 0; }

Output:

Inside function: 15
Outside function: 5

जैसा कि देखा जा सकता है, main function में a की value नहीं बदली।

2. Call by Reference (Pointer method)

  • इस method में variable का address भेजा जाता है।
  • Function के अंदर की गई changes actual variable को affect करती हैं।

Example:

#include <stdio.h> void change(int *x) { *x = *x + 10; printf("Inside function: %d\n", *x); } int main() { int a = 5; change(&a); printf("Outside function: %d", a); return 0; }

Output:

Inside function: 15
Outside function: 15

इस case में actual variable a भी modify हो गया क्योंकि हमने उसका address भेजा था।

Function with No Argument in Hindi

जब कोई function बिना किसी input के काम करता है, तो उसे हम Function with No Argument कहते हैं। इस प्रकार के function को call करने पर उसे कोई भी value नहीं भेजी जाती।

Use:

  • जब function को fixed task करना हो।
  • जब function को external input की आवश्यकता न हो।

Example:

#include <stdio.h> void greet() { printf("Welcome to C Programming!"); } int main() { greet(); // कोई argument नहीं भेजा गया return 0; }

ऊपर example में greet() function को बिना किसी argument के call किया गया है।

Function with Multiple Arguments in Hindi

जब हम एक function को एक से अधिक values भेजते हैं, तो वह Function with Multiple Arguments कहलाता है। इससे function में flexibility आती है और वह dynamic तरीके से काम कर सकता है।

Use:

  • जब function को एक से अधिक data की आवश्यकता हो।
  • जब किसी logic को multiple inputs की जरुरत हो।

Example:

#include <stdio.h> void studentInfo(char name[], int age, float marks) { printf("Name: %s\n", name); printf("Age: %d\n", age); printf("Marks: %.2f\n", marks); } int main() { studentInfo("Rahul", 18, 89.75); return 0; }

इस program में function studentInfo() को तीन arguments दिए गए हैं: एक string, एक integer और एक float।

Benefits of Using Multiple Arguments:

  • Multiple values पर एक साथ कार्य किया जा सकता है।
  • Code modular और reusable बनता है।
  • Function ज्यादा powerful और उपयोगी बनता है।

Important Points:

  • Function definition में arguments की संख्या और type, function call से match होनी चाहिए।
  • Function call करते समय arguments की order भी match होनी चाहिए।
  • Arguments को जरूरत अनुसार value या reference से भेजा जा सकता है।

Example with Calculation:

#include <stdio.h> float calculateAverage(int a, int b, int c) { return (a + b + c) / 3.0; } int main() { float avg = calculateAverage(70, 80, 90); printf("Average Marks: %.2f", avg); return 0; }

यह function तीन arguments को accept करता है और उनका average return करता है।

Real Life Example:

  • मान लीजिए हम एक calculator बना रहे हैं जिसमें addition, subtraction, multiplication सभी functions हों। सभी को कम से कम दो arguments की आवश्यकता होगी।
  • कोई banking application हो जिसमें amount और interest दोनों values पास करनी हो।

Table: Difference Between No Argument and Multiple Argument Functions

Feature No Argument Function Multiple Argument Function
Input कोई भी input नहीं लेता एक या एक से अधिक input लेता है
Flexibility Fixed काम के लिए Dynamic काम के लिए
Example greet() add(a, b), studentInfo(name, age, marks)

FAQs

Function Argument वो value होती है जो हम किसी function को देते हैं ताकि वह उस value पर काम कर सके। इसे हम function call के समय भेजते हैं, और ये value function के अंदर जाकर किसी variable में store हो जाती है।
C language में Function Arguments दो प्रकार के होते हैं: Call by Value और Call by Reference। Call by Value में value की copy भेजी जाती है जबकि Call by Reference में variable का address भेजा जाता है।
ऐसा function जिसे कोई भी input value (argument) न दी जाए, उसे Function with No Argument कहते हैं। ये function किसी fixed काम के लिए होता है और उसे call करते समय कोई भी data pass नहीं किया जाता।
ऐसा function जिसमें एक से अधिक arguments (input values) भेजे जाते हैं, उसे Function with Multiple Arguments कहते हैं। इससे function ज्यादा dynamic और उपयोगी बनता है।
Call by Value में function को variable की copy भेजी जाती है, जिससे main variable पर कोई असर नहीं होता। जबकि Call by Reference में variable का address भेजा जाता है, जिससे function द्वारा किए गए बदलाव main variable पर directly असर डालते हैं।

Please Give Us Feedback