Variables which can be accessed by all modules of the program is called —

2019

Variables which can be accessed by all modules of the program is called —

  1. A.

    Global

  2. B.

    Auto

  3. C.

    Static

  4. D.

    Local

  5. E.

    Dynamic

Attempted by 1077 students.

Show answer & explanation

Correct answer: A

Variables that can be accessed by all modules of a program are known as global variables. These variables are declared outside any function or block and are accessible throughout the entire program.

Auto variables are created within a function and are destroyed when the function ends. They are not accessible outside the function, so they cannot be accessed by all modules.

Static variables retain their value between function calls but are typically limited to the file or function scope unless explicitly declared as global. They are not accessible across all modules by default.

Local variables are confined to the function or block in which they are declared. They cannot be accessed outside their scope, so they do not meet the requirement.

Dynamic variables are created at runtime and their scope depends on how they are declared. They are not guaranteed to be accessible across all modules.

हिन्दी उत्तर: प्रोग्राम के सभी मॉड्यूल द्वारा पहुँचे जा सकने वाले चरों को ग्लोबल चर कहा जाता है। ये चर किसी फंक्शन या ब्लॉक के बाहर घोषित किए जाते हैं और पूरे प्रोग्राम में उपलब्ध होते हैं।

ऑटो चर एक फंक्शन के भीतर बनाए जाते हैं और फंक्शन समाप्त होने पर नष्ट हो जाते हैं। वे फंक्शन के बाहर उपलब्ध नहीं होते हैं, इसलिए वे सभी मॉड्यूल द्वारा नहीं पहुँचे जा सकते हैं।

स्टैटिक चर फंक्शन कॉल के बीच अपना मान बनाए रखते हैं लेकिन आमतौर पर फाइल या फंक्शन स्कोप तक सीमित होते हैं, जब तक कि उन्हें ग्लोबल के रूप में स्पष्ट रूप से घोषित नहीं किया जाता है। वे डिफ़ॉल्ट रूप से सभी मॉड्यूल द्वारा एक्सेस नहीं किए जा सकते हैं।

लोकल चर उस फंक्शन या ब्लॉक में सीमित होते हैं जिसमें वे घोषित किए गए हैं। वे अपने स्कोप के बाहर उपलब्ध नहीं होते हैं, इसलिए वे आवश्यकता को पूरा नहीं करते हैं।

डायनामिक चर रनटाइम पर बनाए जाते हैं और उनका स्कोप उनके घोषणा के तरीके पर निर्भर करता है। वे सभी मॉड्यूल द्वारा एक्सेस के लिए गारंटी नहीं देते हैं।

Explore the full course: Bpsc