Question:
Which data type is used to represent the absence of parameters?
पैरामीटर्स की अनुपस्थिति का प्रतिनिधित्व करने के लिए कौन सा डेटा टाइप इस्तेमाल किया जाता है?
Options:
- int
- short
- float
- void
- int
- शार्ट
- फ्लोट
- शून्य
Correct Answer: d)
Explanation:
Detailed Explanation:
The correct answer is d) void (शून्य).
In C, C++, and Java:
- The keyword
void(translated literally as ‘शून्य’ in the Hindi exam paper) is an incomplete type that denotes the absence of type or value. - Absence of Parameters: When used in a function’s parameter list in C/C++, such as
int getCount(void);,voidexplicitly declares that the function accepts no parameters (absence of parameters). - Absence of Return Value: When used as a function’s return type, such as
void printMessage();, it indicates that the function performs an action but returns no value to the calling environment. - Generic Pointer: A
void*represents a generic pointer that points to a memory address without a specific data type.
विस्तृत व्याख्या:
सही उत्तर d) शून्य (void) है।
C और C++ प्रोग्रामिंग भाषाओं में:
void(प्रश्नपत्र में हिंदी अनुवाद ‘शून्य’): एक विशेष प्रकार का डेटा टाइप है जिसका शाब्दिक अर्थ ‘खाली’ या ‘मान-रहित’ होता है।- पैरामीटर्स की अनुपस्थिति: जब किसी फ़ंक्शन की घोषणा में कोष्ठक के अंदर
voidलिखा जाता है (जैसे:int compute(void);), तो यह स्पष्ट करता है कि फ़ंक्शन कोई भी तर्क (Arguments/Parameters) स्वीकार नहीं करता है। - रिटर्न मान की अनुपस्थिति: यदि इसे फ़ंक्शन के रिटर्न प्रकार के रूप में उपयोग किया जाए (जैसे:
void display();), तो इसका अर्थ है कि फ़ंक्शन कॉलिंग कोड को कोई मान वापस (Return) नहीं करेगा।
अतः पैरामीटर्स की अनुपस्थिति को दर्शाने के लिए void (शून्य) का उपयोग किया जाता है।