Actual Parameters vs Formal Parameters in C Functions Notes in Hindi & English : एक्चुअल पैरामीटर्स बनाम फॉर्मल पैरामीटर्स में मुख्य अंतर और 20 महत्वपूर्ण MCQ प्रश्न (Rajasthan IT Exam)

Post a Comment

PGDCA, BCA, B-Tech, MCA, M-Tech, B.Sc computer science राजस्थान सूचना सहायक व कंप्यूटर शिक्षक विशेष नोट्स: इस अध्याय में हम Actual Parameters vs Formal Parameters in C Functions (एक्चुअल पैरामीटर्स बनाम फॉर्मल पैरामीटर्स में मुख्य अंतर) की संपूर्ण थ्योरी, मुख्य तकनीकी बिंदु, तुलनात्मक तालिका और विगत परीक्षाओं के पैटर्न पर आधारित 20 अति-महत्वपूर्ण बहुविकल्पीय प्रश्न (MCQs) विस्तृत हिंदी व अंग्रेजी व्याख्या सहित पढ़ेंगे।

Overview: Actual parameters (arguments) are the concrete expressions passed at a function call site, while formal parameters are local variables declared in the function header to receive them. In C, argument count and types must align with the prototype, and formal parameters reside in separate callee stack memory.

अध्याय सार: एक्चुअल पैरामीटर्स (Arguments) वे वास्तविक मान या एक्सप्रेशन हैं जो फंक्शन कॉल करते समय भेजे जाते हैं, जबकि फॉर्मल पैरामीटर्स फंक्शन हेडर में घोषित वे स्थानीय चर हैं जो इन मानों को ग्रहण करते हैं। C में इनकी संख्या व टाइप प्रोटोटाइप से मेल खाने आवश्यक हैं और फॉर्मल पैरामीटर्स को कॉली के स्टैक फ्रेम में अलग मेमोरी मिलती है।

Actual Parameters vs Formal Parameters in C Functions: Detailed Notes & Architecture (एक्चुअल पैरामीटर्स बनाम फॉर्मल पैरामीटर्स में मुख्य अंतर)

1. ISO C Terminology & Structural Distinction (मानक C शब्दावली व संरचनात्मक अंतर)

[EN] While academic curricula speak of 'Actual Parameters' and 'Formal Parameters', the ISO C standard specifically names them **Arguments** (expressions in the function call) and **Parameters** (declarations in the function definition header). In 'area(len + 2, 5)', 'len + 2' and '5' are actual parameters; in 'int area(int l, int w)', 'l' and 'w' are formal parameters. Actual parameters may be variables, literals, pointers, or complex expressions, whereas formal parameters must strictly be typed variable declarations.

[HI] शैक्षणिक पाठ्यक्रमों में जिन्हें एक्चुअल व फॉर्मल पैरामीटर कहा जाता है, ISO C मानक में उन्हें क्रमशः **Arguments** (कॉल के समय भेजे गए मान) और **Parameters** (परिभाषा हेडर में घोषित चर) कहते हैं। उदाहरणार्थ 'area(len + 2, 5)' में 'len + 2' और '5' एक्चुअल पैरामीटर्स हैं, तथा 'int area(int l, int w)' में 'l' व 'w' फॉर्मल पैरामीटर्स हैं। एक्चुअल पैरामीटर कोई स्थिरांक या अभिव्यक्ति भी हो सकता है, जबकि फॉर्मल पैरामीटर सदैव मान्य वेरिएबल डिक्लेरेशन होना चाहिए।

2. Memory Isolation, Stack Lifetime & Name Independence (मेमोरी अलगाव, स्टैक जीवनकाल व नाम स्वतंत्रता)

[EN] Actual parameters exist inside the caller's stack frame or as temporary rvalues. Formal parameters are created dynamically inside the callee's stack frame upon call entry and vanish upon return. Even when both share identical names (e.g., 'x' in main and 'x' in calc(int x)), they occupy distinct memory addresses—so modifying formal parameter x never alters caller variable x unless a pointer address was passed.

[HI] एक्चुअल पैरामीटर्स कॉलर के स्टैक फ्रेम (या अस्थायी मान) में रहते हैं, जबकि फॉर्मल पैरामीटर्स फंक्शन कॉल होते ही कॉली के नए स्टैक फ्रेम में बनते हैं और return पर नष्ट हो जाते हैं। यदि दोनों का नाम एक समान (जैसे main में x और calc में int x) हो, तब भी दोनों अलग-अलग मेमोरी पतों पर स्थित होते हैं और एक में बदलाव दूसरे को प्रभावित नहीं करता।

3. Type Checking, Implicit Conversions & Array Decay (टाइप जांच, इम्प्लिसिट कन्वर्जन व एरे डिके नियम)

[EN] Given a visible prototype, C enforces positional argument matching and applies implicit assignment-like conversions (e.g., passing int 4 into a double parameter converts it to 4.0). A crucial C pitfall involves array parameters: writing 'void fn(int arr[10])' is adjusted by the compiler to 'void fn(int *arr)'. Hence, inside fn, sizeof(arr) yields pointer size (4 or 8 bytes) rather than 40 bytes—you must pass array length as an extra argument.

[HI] प्रोटोटाइप उपलब्ध होने पर C क्रम के अनुसार संख्या की जांच करता है और संगत मानों का स्वतः रूपांतरण (जैसे int 4 का double 4.0 में) करता है। एक बड़ा परीक्षा-बिंदु एरे पैरामीटर है: 'void fn(int arr[10])' को कंपाइलर वास्तव में पॉइंटर 'int *arr' बना देता है, अतः fn के अंदर sizeof(arr) एरे का पूरा आकार नहीं बल्कि केवल पॉइंटर का आकार (4 या 8 बाइट) लौटाता है।

4. Variadic Functions, Default Promotions & C Constraints (वेरिएडिक फंक्शन, डिफ़ॉल्ट प्रमोशन व C की सीमाएँ)

[EN] Variadic functions like printf(const char *fmt, ...) have no named formal parameters for trailing arguments and read them via <stdarg.h>. For unnamed variadic arguments, C enforces Default Argument Promotions: char and short promote to int, and float promotes automatically to double. Unlike C++ and Python, standard C supports neither default parameter values (int f(int x = 1)) nor named keyword arguments.

[HI] printf जैसे वेरिएडिक फंक्शन्स ('...') में अतिरिक्त एक्चुअल आर्गुमेंट्स के लिए नामित फॉर्मल पैरामीटर नहीं होते और इन्हें <stdarg.h> से पढ़ा जाता है। ऐसे अनाम आर्गुमेंट्स पर डिफ़ॉल्ट आर्गुमेंट प्रमोशन लागू होता है—char व short स्वतः int में तथा float स्वतः double में बदल जाता है। C++ या Python के विपरीत मानक C में डिफ़ॉल्ट पैरामीटर मान (int x = 1) या कीवर्ड आर्गुमेंट की सुविधा नहीं होती।

Syntax, Formula & Technical Example (Actual Parameters vs Formal Parameters in C Functions)

#include <stdio.h>
int calcArea(int len, int wid) { // Formal parameters: len, wid
    len += 2;                    // Modifies callee stack copy only
    return len * wid;
}
int main(void) {
    int x = 5, y = 4, res = calcArea(x + 1, y); // Actual: (x+1), y
    printf("x=%d, res=%d\n", x, res); // Output: x=5, res=32
    return 0;
}

Actual Parameters vs Formal Parameters in C Functions Quick Reference & Comparison Table

Parameter AspectActual Parameters (Arguments)Formal Parameters (Parameters)
Program LocationPlaced in the function call expressionDeclared inside function definition header
Permitted SyntaxConstants, variables, or expressions (x+1)Typed variable identifiers only (no literals)
Memory & LifetimeReside in caller frame or temporary rvaluesAllocated in callee stack frame per call
ISO C NomenclatureOfficially called ArgumentsOfficially called Parameters

Actual Parameters vs Formal Parameters in C Functions Top 20 Bilingual MCQs with Answers

Q1. Where do actual parameters appear in a C program?

(C प्रोग्राम में एक्चुअल पैरामीटर्स कहाँ लिखे जाते हैं?)

(A) Inside the function call site when invoking the function

(B) Inside the function definition header

(C) Inside a struct definition

(D) Only inside #define macros

Correct Answer: (A)

[EN] Actual parameters (arguments) are the concrete values or expressions passed inside parentheses when calling a function.

[HI] एक्चुअल पैरामीटर्स वे मान या एक्सप्रेशन होते हैं जिन्हें फंक्शन को कॉल करते समय कोष्ठक में भेजा जाता है।

Q2. Which of the following is NOT valid as a formal parameter in a C function definition?

(C फंक्शन परिभाषा के हेडर में इनमें से क्या फॉर्मल पैरामीटर के रूप में अमान्य है?)

(A) A literal constant or expression like 'void f(int a + b, 5)'

(B) A struct variable like 'void f(struct Point p)'

(C) A pointer declaration like 'void f(int *p)'

(D) A register variable like 'void f(register int x)'

Correct Answer: (A)

[EN] Formal parameters must be declared variable identifiers that can hold incoming argument values.

[HI] फॉर्मल पैरामीटर केवल मान्य वेरिएबल डिक्लेरेशन हो सकते हैं; लिटरल संख्या या गणितीय अभिव्यक्तियाँ अवैध हैं।

Q3. According to official ISO C standard terminology, what are actual and formal parameters called respectively?

(आधिकारिक ISO C मानक शब्दावली में एक्चुअल और फॉर्मल पैरामीटर्स को क्रमशः क्या कहा जाता है?)

(A) Lvalues and Rvalues

(B) Operands and Operators

(C) Parameters (actual) and Arguments (formal)

(D) Arguments (actual) and Parameters (formal)

Correct Answer: (D)

[EN] ISO C strictly uses 'argument' for the call-site expression and 'parameter' for the receiving variable in the header.

[HI] ISO C में कॉल पर भेजे गए मान को 'Argument' और फंक्शन हेडर के ग्रहण करने वाले चर को 'Parameter' कहा जाता है।

Q4. If main() declares 'int n = 10;' and calls 'fun(n)' where 'void fun(int n) { n = 99; }', what is n in main() afterward?

(यदि main() में 'int n = 10;' हो और 'void fun(int n) { n = 99; }' को fun(n) से कॉल करें, तो बाद में main() में n का मान क्या होगा?)

(A) 0

(B) Compile error due to duplicate name n

(C) 10

(D) 99

Correct Answer: (C)

[EN] Formal parameter n in fun() occupies its own callee stack slot distinct from main()'s n, leaving main()'s n at 10.

[HI] दोनों का नाम n होने पर भी दोनों की स्टैक मेमोरी अलग है, अतः fun() में बदलाव के बाद भी main() का n 10 ही रहेगा।

Q5. On a 64-bit platform (sizeof(int)=4, sizeof(int*)=8), what does 'void f(int a[10]) { printf("%zu", sizeof(a)); }' print?

(64-बिट सिस्टम (जहाँ sizeof(int)=4, sizeof(int*)=8) पर 'void f(int a[10]) { printf("%zu", sizeof(a)); }' क्या प्रिंट करेगा?)

(A) 4

(B) 10

(C) 8

(D) 40

Correct Answer: (C)

[EN] In C parameter lists, 'int a[10]' decays to 'int *a', so sizeof(a) returns the size of the pointer (8), not 40.

[HI] फंक्शन पैरामीटर में एरे डिके होकर पॉइंटर int *a बन जाता है, जिससे sizeof(a) पूरे एरे के बजाय पॉइंटर का आकार (8) लौटाता है।

Q6. What happens when calling a prototyped function 'void add(int a, int b);' with 'add(5);'?

(प्रोटोटाइप 'void add(int a, int b);' वाले फंक्शन को 'add(5);' से कॉल करने पर क्या होता है?)

(A) b takes garbage silently

(B) Runtime crash

(C) Compile-time error ('too few arguments to function')

(D) b defaults to 0 automatically

Correct Answer: (C)

[EN] ISO C requires the exact number of actual arguments to match the formal parameter list (except variadics).

[HI] मानक C में कॉल के समय एक्चुअल और फॉर्मल पैरामीटर्स की संख्या समान होना अनिवार्य है, अतः कम आर्गुमेंट पर कंपाइल एरर आता है।

Q7. Given 'void show(double d) { printf("%.1f", d); }', what prints when calling 'show(7);'?

('void show(double d) { printf("%.1f", d); }' को 'show(7);' से कॉल करने पर क्या प्रिंट होगा?)

(A) 0.0

(B) 7.0

(C) Garbage float

(D) Compile error due to int/double mismatch

Correct Answer: (B)

[EN] Because the prototype specifies double, C implicitly converts actual integer argument 7 to double 7.0.

[HI] प्रोटोटाइप के कारण C कंपाइलर एक्चुअल int मान 7 को स्वतः double 7.0 में रूपांतरित कर देता है और 7.0 प्रिंट होता है।

Q8. Under C's Default Argument Promotions, when passing a 'float' to the '...' part of printf(), what type does it become?

(C के डिफ़ॉल्ट आर्गुमेंट प्रमोशन के तहत printf() के '...' भाग में 'float' भेजने पर वह किस टाइप में बदलता है?)

(A) double

(B) Remains 32-bit float

(C) long float

(D) int

Correct Answer: (A)

[EN] Trailing arguments in variadic calls automatically promote float to double, and char/short to int.

[HI] वेरिएडिक फंक्शनों में अनाम आर्गुमेंट होने पर float स्वतः double में और char/short स्वतः int में प्रमोट हो जाते हैं।

Q9. When is stack memory allocated and released for formal parameters of a C function?

(C फंक्शन के फॉर्मल पैरामीटर्स के लिए मेमोरी कब आवंटित और मुक्त की जाती है?)

(A) Allocated on the stack when the function is called and freed when it returns

(B) Allocated at compile time and kept forever

(C) Allocated only if modified

(D) Allocated on the heap using malloc()

Correct Answer: (A)

[EN] Formal parameters have automatic storage duration tied strictly to the lifetime of that function call.

[HI] फॉर्मल पैरामीटर्स की मेमोरी फंक्शन कॉल होते ही स्टैक पर बनती है और return करते ही मुक्त हो जाती है।

Q10. Which actual parameter call is valid for 'int compute(int a, int b, int c)'?

('int compute(int a, int b, int c)' के लिए इनमें से कौन सी फंक्शन कॉल वैध है?)

(A) compute(int x, int y, int z)

(B) compute(10, , 20)

(C) compute(x * 2, getVal(), 45)

(D) compute(10, 20)

Correct Answer: (C)

[EN] Actual parameters can combine variables, arithmetic expressions, function calls, and literals; types should not be written in calls.

[HI] एक्चुअल पैरामीटर्स में वेरिएबल, अभिव्यक्तियाँ, अन्य फंक्शन कॉल या स्थिरांक पास किए जा सकते हैं, पर कॉल में डेटा टाइप नहीं लिखा जाता।

Q11. Which storage-class specifier is legally permitted in a C formal parameter declaration?

(C के फॉर्मल पैरामीटर डिक्लेरेशन में इनमें से कौन सा स्टोरेज-क्लास स्पेसिफायर मान्य है?)

(A) register

(B) static

(C) extern

(D) typedef

Correct Answer: (A)

[EN] ISO C permits ONLY 'register' (e.g., void f(register int x)) inside parameter declarations; static, extern, and auto are invalid.

[HI] मानक C में पैरामीटर लिस्ट में केवल 'register' कीवर्ड की ही अनुमति है; static, extern या typedef लिखना अवैध है।

Q12. What does 'int f(int p, int q) { return p * q; }' print when called via 'int x = 3; printf("%d", f(x + 2, x));'?

(यदि 'int f(int p, int q) { return p * q; }' को 'int x = 3; printf("%d", f(x + 2, x));' से कॉल करें, तो क्या प्रिंट होगा?)

(A) Compile error

(B) 11

(C) 15

(D) 9

Correct Answer: (C)

[EN] Actual arguments evaluate to 5 and 3, copying 5 into p and 3 into q, so 5 * 3 = 15 returns.

[HI] एक्चुअल पैरामीटर्स का मान 5 और 3 निकलता है जो p व q में कॉपी होता है, जिससे 5 * 3 = 15 प्रिंट होता है।

Q13. How are actual parameters matched to formal parameters in C?

(C में एक्चुअल पैरामीटर्स का मिलान फॉर्मल पैरामीटर्स से किस आधार पर होता है?)

(A) Using Python-style keyword syntax like func(b=2, a=1)

(B) Alphabetically by identifier name

(C) By matching identical variable names

(D) Strictly by positional order from left to right

Correct Answer: (D)

[EN] C maps the 1st actual argument to the 1st formal parameter, 2nd to 2nd, and so on strictly by position.

[HI] C में मिलान केवल बाएँ से दाएँ स्थिति (Position) के आधार पर होता है; नाम समान होना आवश्यक नहीं है।

Q14. Which statement is NOT true regarding actual and formal parameters in C?

(C में एक्चुअल और फॉर्मल पैरामीटर्स के बारे में इनमें से कौन सा कथन असत्य है?)

(A) C allows formal parameters to declare default values like 'int f(int x = 5)'

(B) Actual parameters may be constant expressions

(C) Matching occurs strictly positionally

(D) Formal parameters live in the callee stack frame

Correct Answer: (A)

[EN] Standard C does NOT support default argument values (unlike C++); all arguments must be supplied at call.

[HI] मानक C (C++ के विपरीत) फॉर्मल पैरामीटर्स में 'int x = 5' जैसे डिफ़ॉल्ट मान देने की सुविधा नहीं देता।

Q15. Why must scanf("%lf", &f) NOT be used when f is a 32-bit float variable?

(यदि f एक 32-बिट float वेरिएबल है, तो scanf("%lf", &f) क्यों नहीं लिखना चाहिए?)

(A) scanf automatically converts float* to double*

(B) %lf works only for integers

(C) Address of float cannot be taken

(D) scanf expects a 64-bit double* for %lf and overwrites adjacent memory past 4-byte float f

Correct Answer: (D)

[EN] Pointers do not undergo default promotion; %lf writes 8 bytes through a 4-byte float* address, corrupting memory.

[HI] पॉइंटर पैरामीटर्स में स्वतः प्रमोशन नहीं होता; %lf 4-बाइट वाले float में 8 बाइट लिखकर मेमोरी खराब कर देगा।

Q16. What happens when calling 'void setup(void)' with an argument 'setup(1);'?

('void setup(void)' प्रोटोटाइप वाले फंक्शन को 'setup(1);' से कॉल करने पर क्या होता है?)

(A) 1 is silently ignored

(B) 1 prints to stdout

(C) setup runs once

(D) Compile-time error ('too many arguments to function')

Correct Answer: (D)

[EN] (void) explicitly declares zero formal parameters, so passing any actual argument violates the signature.

[HI] (void) स्पष्ट करता है कि कोई पैरामीटर नहीं है, इसलिए कोई भी आर्गुमेंट पास करने पर कंपाइल एरर आएगा।

Q17. Within Actual Parameters vs Formal Parameters in C Functions, which parameter aspect directly maps to: "Placed in the function call expression"?

(Actual Parameters vs Formal Parameters in C Functions में कौन सा Parameter Aspect सीधे "Placed in the function call expression" से संबंधित है?)

(A) Program Location

(B) Permitted Syntax

(C) Memory & Lifetime

(D) ISO C Nomenclature

Correct Answer: (A)

[EN] In Actual Parameters vs Formal Parameters in C Functions, 'Program Location' handles 'Placed in the function call expression' (Declared inside function definition header).

[HI] Actual Parameters vs Formal Parameters in C Functions में 'Program Location' का कार्य/विवरण 'Placed in the function call expression' (Declared inside function definition header) है।

Q18. Which option accurately describes 'Permitted Syntax' in Actual Parameters vs Formal Parameters in C Functions?

(Actual Parameters vs Formal Parameters in C Functions के संदर्भ में 'Permitted Syntax' की सही विशेषता कौन सी है?)

(A) Placed in the function call expression

(B) Constants, variables, or expressions (x+1)

(C) Officially called Arguments

(D) Reside in caller frame or temporary rvalues

Correct Answer: (B)

[EN] 'Permitted Syntax' provides 'Constants, variables, or expressions (x+1)' — key point: Typed variable identifiers only (no literals).

[HI] 'Permitted Syntax' का मुख्य विवरण 'Constants, variables, or expressions (x+1)' है (Typed variable identifiers only (no literals))।

Q19. In Actual Parameters vs Formal Parameters in C Functions, identify the correct parameter for the specification: "Reside in caller frame or temporary rvalues".

(Actual Parameters vs Formal Parameters in C Functions में "Reside in caller frame or temporary rvalues" विवरण किस विकल्प के लिए सही है?)

(A) Program Location

(B) Memory & Lifetime

(C) Permitted Syntax

(D) ISO C Nomenclature

Correct Answer: (B)

[EN] 'Memory & Lifetime' corresponds to 'Reside in caller frame or temporary rvalues' (Allocated in callee stack frame per call).

[HI] 'Memory & Lifetime' का संबंध 'Reside in caller frame or temporary rvalues' (Allocated in callee stack frame per call) से है।

Q20. Considering Actual Parameters vs Formal Parameters in C Functions, what key behavior defines 'ISO C Nomenclature'?

(Actual Parameters vs Formal Parameters in C Functions में 'ISO C Nomenclature' की मुख्य भूमिका या मान क्या है?)

(A) Constants, variables, or expressions (x+1)

(B) Placed in the function call expression

(C) Reside in caller frame or temporary rvalues

(D) Officially called Arguments

Correct Answer: (D)

[EN] 'ISO C Nomenclature' represents 'Officially called Arguments' (Officially called Parameters).

[HI] 'ISO C Nomenclature' का अर्थ/मान 'Officially called Arguments' है (Officially called Parameters)।

Actual Parameters vs Formal Parameters in C Functions — Exam FAQs

Q1: If my actual parameter and formal parameter share the same name 'x', why doesn't changing x inside the function change main's x?

यदि मेरे एक्चुअल व फॉर्मल पैरामीटर दोनों का नाम 'x' हो, तो फंक्शन में x बदलने पर main का x क्यों नहीं बदलता?

[EN] Because each function receives its own separate stack frame; main's 'x' and the function's formal 'x' live at completely different memory addresses unless you explicitly pass '&x' into a pointer.

[HI] क्योंकि दोनों फंक्शनों का स्टैक फ्रेम और मेमोरी पता अलग होता है; एक ही नाम होने के बावजूद दोनों अलग वेरिएबल होते हैं।

Q2: Why does sizeof(arr) inside a function return 4 or 8 instead of the array's byte size?

किसी फंक्शन के अंदर sizeof(arr) पूरे एरे का आकार न बताकर 4 या 8 क्यों लौटाता है?

[EN] In C, an array parameter like int arr[] automatically decays into a pointer int *arr, so sizeof(arr) measures only the size of a memory pointer—always pass the array's element count as a separate parameter.

[HI] C में फंक्शन पैरामीटर के रूप में पास एरे पॉइंटर में बदल जाता है, इसलिए sizeof केवल पॉइंटर का आकार लौटाता है; एरे की लंबाई अलग पैरामीटर में भेजनी चाहिए।

Q3: Does C support default parameter values or named keyword arguments?

क्या C भाषा में डिफ़ॉल्ट पैरामीटर वैल्यू या नामित कीवर्ड आर्गुमेंट्स समर्थित हैं?

[EN] No. Standard C requires every formal parameter to receive a positional actual argument at the call site (features like default values and overloading exist in C++, not C).

[HI] नहीं। मानक C में हर पैरामीटर के लिए कॉल के समय क्रम से मान भेजना आवश्यक है (डिफ़ॉल्ट मान जैसी सुविधाएँ C++ में होती हैं, C में नहीं)।

Related Posts

  • Loading related posts...

Post a Comment

Search Topic Notes & 20 MCQs (Hindi / English)