FliQi Education App Download
प्रश्न-बैंक · C Language

Constants of C Language — प्रश्न और उत्तर

C Language · 20 जाँचे हुए (verified) प्रश्न

  • 20 जाँचे हुए प्रश्न
  • हिंदी + English

पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 10 के उत्तर और हल FliQi Question Bank app में।

भाषा
प्रश्न 1उत्तर + हल
कौन-सा प्राथमिक स्थिरांक (primary constant) नहीं है?
Which one is not a primary constant?
  1. AInteger Constant
  2. BReal constant
  3. CCharacter constant
  4. DEnum constant

सही उत्तर / Answer: (D)

हल / Solution
C के स्थिरांक दो वर्गों में बाँटे जाते हैं — प्राथमिक (primary) और द्वितीयक (secondary)। प्राथमिक में तीन ही आते हैं: पूर्णांक स्थिरांक (integer constant), वास्तविक स्थिरांक (real constant) और वर्ण स्थिरांक (character constant), क्योंकि ये सीधे एक मान बताते हैं। enum स्थिरांक इस सूची में नहीं है; वह गणनाकृत प्रकार (enumeration) के साथ बनता है और द्वितीयक वर्ग में गिना जाता है।
Constants in C are grouped into primary and secondary types. Only three belong to the primary group: integer constants, real constants and character constants, because each of them directly states a single value. An enum constant is not in that list. It is created along with an enumeration type, which also covers arrays, pointers, structures and unions, so it is counted in the secondary group of constants.
प्रश्न 2उत्तर + हल
मान्य (valid) कथन खोजिए।
Find Valid
  1. Achar ch = ‘’;
  2. Bchar ch = "A";
  3. Cchar ch = ‘A’;
  4. DAll are Valid

सही उत्तर / Answer: (C)

हल / Solution
एकल उद्धरण के बीच ठीक एक वर्ण हो, तभी वह वैध वर्ण स्थिरांक है — इसलिए char ch = ‘A’; मान्य है। पहले विकल्प में उद्धरणों के बीच कुछ भी नहीं, यानी ख़ाली वर्ण स्थिरांक, और कंपाइलर इसी पर त्रुटि देता है। दूसरे में "A" स्ट्रिंग है, जिसके अंत में null वर्ण जुड़ा होता है और जो char में नहीं समाता। सो चौथा विकल्प भी ग़लत है।
A valid character constant needs exactly one character between the single quotes, so char ch = ‘A’; is the right statement. The first choice has nothing between the quotes, that is an empty character constant, and the compiler reports an error on it. In the second choice the double quoted form is a string with a null character added at its end, which cannot fit in a char. So the last choice is wrong too.
प्रश्न 3उत्तर + हल
अमान्य कथन खोजें।
Find the invalid statement.
  1. Achar ch = '\p';
  2. Bchar ch = '\t';
  3. Cchar ch = '\b';
  4. Dchar ch = '\0';

सही उत्तर / Answer: (A)

हल / Solution
Backslash के बाद कोई ख़ास अक्षर आए तो उसे escape sequence कहते हैं। C में इनका तय समूह है, जैसे \n, \t, \b, \0, \a और \\। \p इनमें नहीं है, इसलिए '\p' अमान्य है। standard इस पर diagnostic माँगता है और cc unknown escape sequence की चेतावनी देता है। बाक़ी सही हैं। '\t' horizontal tab है। '\b' backspace है, जो cursor को एक जगह पीछे ले जाता है। '\0' null character है।
An escape sequence is a backslash followed by a special character. C defines only a fixed set, such as \n, \t, \b, \0, \a and \\. \p is not one of them, so '\p' is invalid; the standard requires a diagnostic and cc warns about an unknown escape sequence. The others are valid: '\t' is the horizontal tab, '\b' is backspace (it moves the cursor one place back), and '\0' is the null character.
प्रश्न 4उत्तर + हल
अमान्य कथन खोजें।
Find the invalid statement.
  1. Achar ch = '\a';
  2. Bchar ch = '\\';
  3. Cchar ch = '\m';
  4. Dchar ch = '\n';

सही उत्तर / Answer: (C)

हल / Solution
Character constant में backslash से escape sequence शुरू होता है। C में इनका एक तय समूह है, जैसे \n, \t, \a, \b, \0 और \\। \m इस समूह में नहीं है। C standard के हिसाब से इस पर diagnostic ज़रूरी है और cc unknown escape sequence की चेतावनी देता है। इसलिए विकल्प 3 अमान्य है। बाक़ी सही हैं। '\a' alert यानी beep है, '\\' एक backslash है और '\n' नई पंक्ति है।
A backslash inside a character constant starts an escape sequence, and C allows only a fixed set, such as \n, \t, \a, \b, \0 and \\. \m is not in this set. The C standard requires a diagnostic for it, and cc warns about an unknown escape sequence, so option 3 is invalid. The rest are valid: '\a' is the alert (beep) character, '\\' is one backslash, and '\n' is the newline.
प्रश्न 5उत्तर + हल
मान्य कथन खोजें।
Find the valid statement.
  1. Achar ch = '5';
  2. Bchar ch = 'x';
  3. Cchar ch = ' ';
  4. Dसभी मान्य हैंAll are valid

सही उत्तर / Answer: (D)

हल / Solution
Character constant का मतलब है single quotes के अंदर एक अक्षर। '5' अंक वाला character है, संख्या 5 नहीं; इसका ASCII मान 53 है। 'x' छोटा अक्षर है। ' ' में एक space है, और space भी एक character है, जिसका ASCII मान 32 है। तीनों में quotes के अंदर ठीक एक character है, इसलिए तीनों घोषणाएँ बिना error के compile होती हैं। इसलिए सही उत्तर है — सभी मान्य हैं। किसी एक को चुनना अधूरा होगा।
A character constant is one character inside single quotes. '5' is the digit character 5 (ASCII 53), not the number 5. 'x' is a small letter. ' ' holds one space, and a space is also a character (ASCII 32). Each of the three has exactly one character inside the quotes, so all three declarations compile without error. That is why the answer is All are valid; choosing only one would be incomplete.
प्रश्न 6उत्तर + हल
किस कथन से f में अनंत (infinity) बनेगा?
Which statement gives infinity in f?
  1. Afloat f = 0.65e4;
  2. Bfloat f = 12e-2;
  3. Cfloat f = 3.18E3;
  4. Dfloat f = 3.18e50;

सही उत्तर / Answer: (D)

हल / Solution
float का सबसे बड़ा सीमित मान लगभग 3.4e38 होता है। 3.18e50 इस सीमा से बहुत बड़ा है। IEEE 754 मानने वाले सिस्टम पर, यानी आज के लगभग हर कंप्यूटर पर, यह मान float में जाकर infinity बन जाता है और printf में inf छपता है। यह compile error नहीं है। बाक़ी मान आराम से सीमा में हैं। 0.65e4 = 6500, 12e-2 = 0.12 और 3.18E3 = 3180। इसलिए infinity सिर्फ़ विकल्प 4 में बनती है।
The largest finite float value is about 3.4e38. 3.18e50 is far above this limit. On systems that follow IEEE 754, which means almost every computer today, the value becomes infinity when stored in a float, and printf shows inf. It is not a compile error. The other values fit easily: 0.65e4 is 6500, 12e-2 is 0.12, and 3.18E3 is 3180. So only option 4 gives infinity.
प्रश्न 7उत्तर + हल
अमान्य कथन खोजें।
Find the invalid statement.
  1. Adouble d = 0125.03;
  2. Bdouble d = 0x125Face;
  3. Cdouble d = 0XFace.123;
  4. Ddouble d = 0125;

सही उत्तर / Answer: (C)

हल / Solution
बिंदु वाला hexadecimal स्थिरांक hexadecimal floating स्थिरांक होता है, और उसमें p वाला binary घातांक ज़रूरी है, जैसे 0XFace.123p0। 0XFace.123 में p वाला हिस्सा नहीं है, इसलिए compiler error देता है। बाक़ी तीनों सही हैं। 0125.03 decimal real स्थिरांक है, आगे के 0 से फ़र्क़ नहीं पड़ता। 0x125Face एक hexadecimal पूर्णांक है। 0125 octal पूर्णांक है, जिसका मान 85 है और d में 85.0 जाता है।
A hexadecimal constant with a point is a hexadecimal floating constant, and C requires a binary exponent with p, such as 0XFace.123p0. 0XFace.123 has no p part, so the compiler gives an error. The other three are valid: 0125.03 is a decimal real constant (the leading 0 does not matter), 0x125Face is a hexadecimal integer, and 0125 is an octal integer (85) stored in d as 85.0.
प्रश्न 8उत्तर + हल
अमान्य कथन खोजें।
Find the invalid statement.
  1. Afloat f = 010;
  2. Bfloat f = 0789;
  3. Cfloat f = 0125.123;
  4. Dfloat f = 0xca123;

सही उत्तर / Answer: (B)

हल / Solution
0789 शून्य से शुरू होता है और इसमें दशमलव बिंदु नहीं है, इसलिए C इसे octal पूर्णांक पढ़ता है। octal में सिर्फ़ 0 से 7 तक के अंक चलते हैं, 8 और 9 की वजह से यह अमान्य है। बाक़ी सही हैं। 010 octal में 8 है, तो f में 8.0 जाता है। 0125.123 में बिंदु है, इसलिए यह decimal real स्थिरांक है, आगे का 0 इसे octal नहीं बनाता। 0xca123 सही hexadecimal पूर्णांक है।
0789 starts with 0 and has no decimal point, so C reads it as an octal integer. Octal allows only the digits 0 to 7, so 8 and 9 make it invalid. The others are valid: 010 is octal 8, so f gets 8.0. 0125.123 has a decimal point, so it is a decimal real constant and the leading 0 does not make it octal. 0xca123 is a valid hexadecimal integer.
प्रश्न 9उत्तर + हल
अमान्य कथन खोजें।
Find the invalid statement.
  1. Aint a = 0B10110;
  2. Bint a = 0789;
  3. Cint a = 777;
  4. Dfloat b = 0B1001;

सही उत्तर / Answer: (B)

हल / Solution
0 से शुरू होने वाला integer स्थिरांक octal माना जाता है, इसलिए उसमें सिर्फ़ 0 से 7 तक के अंक आ सकते हैं। 0789 में 8 और 9 हैं, इसलिए यह अमान्य है। 777 एक सामान्य decimal पूर्णांक है। 0B10110 (मान 22) और 0B1001 (मान 9) binary स्थिरांक हैं। ये C23 से standard में हैं और GCC, Clang इन्हें पहले से मानते हैं। binary मान float में भी रखा जा सकता है, वहाँ यह 9.0 बनता है।
An integer constant that starts with 0 is octal, so it may use only the digits 0 to 7. 0789 has 8 and 9, so it is invalid and the compiler reports an invalid digit. 777 is a normal decimal integer. 0B10110 (22) and 0B1001 (9) are binary constants; they are standard since C23, and GCC and Clang accepted them earlier. A binary value can also go into a float, where it becomes 9.0.
प्रश्न 10उत्तर + हल
अमान्य कथन खोजें।
Find the invalid statement.
  1. Afloat f = -.71;
  2. Bfloat f = 0xFace.80;
  3. Cfloat f = +.5;
  4. Dfloat f = 0107;

सही उत्तर / Answer: (B)

हल / Solution
Hexadecimal floating स्थिरांक में p वाला binary घातांक ज़रूरी है, जैसे 0xFace.8p0। 0xFace.80 में दशमलव बिंदु तो है पर p वाला हिस्सा नहीं है, इसलिए compiler error देता है। इसलिए विकल्प 2 अमान्य है। बाक़ी सही हैं। -.71 और +.5 चिह्न वाले real स्थिरांक हैं, जिनमें बिंदु से पहले अंक नहीं है। 0107 एक octal पूर्णांक है, जिसका मान 71 है। float में यह 71.0 बनकर जाता है।
A hexadecimal floating constant must have a binary exponent written with p, like 0xFace.8p0. 0xFace.80 has a point but no p part, so the compiler says an exponent is required. That makes option 2 invalid. The others are fine: -.71 and +.5 are signed real constants with no digit before the point, and 0107 is an octal integer (71) that is stored in f as 71.0.
आगे के 10 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 12उत्तर app में
भिन्न प्रकार के पूर्णांक स्थिरांक लिखने के लिए कौन-सा कथन मान्य है?
Which statement is valid for writing different integer constants?
  1. Aunsigned int a = 56789U;
  2. Bunsigned long int a = 98765432UL;
  3. Clong int a = 98765543L;
  4. Dसभी मान्य हैंAll are valid
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Constants of C Language के सभी 20 प्रश्न — उत्तर, हल और अभ्यास

FliQi Question Bank app में topic-वार अभ्यास, कठिनाई-स्तर और आपकी प्रगति।

  • पहला test मुफ़्त
  • हिंदी + English
  • जाँचे हुए उत्तर और हल

यह topic किन परीक्षाओं में आता है

C Language के दूसरे topics

सभी topics