पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
कौन-सी अभिव्यक्ति दिए कथन को परिभाषित करता है - जाँच करें कि 3 चरों age 1, age2 तथा age 3 का मान एक दूसरे के बराबर है। Informatics Assistant Exam 2023
Which expression defines the given statement - check whether the values of the three variables age 1, age2 and age3 are equal to one another? Informatics Assistant Exam 2023
Aage1 = age2 = age3
Bage1 = = age2 and age2 = = age3
Cage1 ! = age2 ! = age3
Dage1 = age2 and age2 = age3
सही उत्तर / Answer: (B)
हल / Solution
तीनों चरों के बराबर होने की जाँच करनी है, उनमें मान भरना नहीं। तुलना का संचालक (operator) == है, और एक ही बार में तीन चर नहीं जोड़े जा सकते — पहले पहले दो की जाँच, फिर अगले दो की, और दोनों शर्तें साथ सत्य होनी चाहिए। विकल्प 2 ठीक यही कहता है। विकल्प 1 और 4 में बराबर का एक ही चिह्न है, सो वे मान भरते हैं; विकल्प 3 में असमानता जाँची जाती है, बराबरी नहीं।
The task is to check whether the three variables are equal, not to put values into them. The comparison operator is ==, and three variables cannot be joined in one step: first the first two are tested, then the next two, and both tests must hold at the same time. Option 2 says exactly that. Options 1 and 4 use a single equals sign, so they assign values instead, and option 3 tests inequality rather than equality.
प्रश्न 2उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int k = 8; int m = 7; int z = k>m ? k = m : m++; printf("%d %d %d", z, k, m); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int k = 8; int m = 7; int z = k>m ? k = m : m++; printf("%d %d %d", z, k, m); return 0; }
A7 7 7
B7 8 9
C8 7 7
D7 8 7
सही उत्तर / Answer: (A)
हल / Solution
शर्त k > m यानी 8 > 7 सच है। इसलिए बीच वाला हिस्सा k = m चलता है। k को 7 मिलता है और इस assignment का मान 7 z में जाता है। तीसरा हिस्सा m++ चलता ही नहीं, इसलिए m 7 रहता है। output "7 7 7" है। 7 8 9 और 7 8 7 मानते हैं कि k नहीं बदला, और 8 7 7 मानता है कि z को k का पुराना मान मिला।
The condition k > m, that is 8 > 7, is true. So the middle part k = m runs. k becomes 7, and the value of this assignment, 7, goes into z. The third part m++ is never executed, so m stays 7. The output is "7 7 7". 7 8 9 and 7 8 7 assume k did not change, and 8 7 7 assumes z got the old k.
प्रश्न 3उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int y = 1, x = 0; int z = (y++, x++) ? y : x; printf("%d", z); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int y = 1, x = 0; int z = (y++, x++) ? y : x; printf("%d", z); return 0; }
A1
B2
C0
DGarbage
सही उत्तर / Answer: (A)
हल / Solution
comma operator बाएँ से दाएँ चलता है और उसका मान सबसे दाएँ हिस्से का होता है। (y++, x++) में पहले y 2 बनता है। फिर x++ पुराना मान 0 देता है और x को 1 कर देता है। इसलिए शर्त 0 यानी झूठ है और तीसरा हिस्सा x चुना जाता है। इस समय x = 1 है, तो z = 1 छपता है। 2 y का मान है, 0 x का पुराना मान, और garbage नहीं आता।
The comma operator runs left to right, and its value is that of the rightmost part. In (y++, x++), y first becomes 2. Then x++ gives the old value 0 and makes x equal to 1. So the condition is 0, which is false, and the third part x is chosen. At this point x is 1, so z = 1 is printed. 2 is y, 0 is the old x, and no garbage appears.
प्रश्न 4उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int x = 2, y = 0; int z = (y++) ? y == 1 && x : 0; printf("%d\n", z); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int x = 2, y = 0; int z = (y++) ? y == 1 && x : 0; printf("%d\n", z); return 0; }
A1
B0
C2
DCompile Time Error
सही उत्तर / Answer: (B)
हल / Solution
y++ post-increment है: यह पहले y का पुराना मान 0 देता है, फिर y को 1 करता है। इसलिए शर्त का मान 0 यानी झूठ है। झूठ होने से बीच वाला हिस्सा y == 1 && x चलता ही नहीं। तीसरा हिस्सा 0 चुना जाता है, इसलिए z = 0 छपता है। मान 1 तब आता जब y++ की जगह ++y होता। मान 2 सिर्फ़ x है, और code बिना error के compile होता है।
y++ is a post-increment: it gives the old value of y, which is 0, and then makes y equal to 1. So the condition is 0, which is false. Because the condition is false, the middle part y == 1 && x is never evaluated. The third part, 0, is chosen, so z = 0 is printed. The answer 1 would appear with ++y instead of y++. 2 is just x, and the code compiles without error.
प्रश्न 5उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int a = 0; a = 7 ? 5 : 1; printf("%d",a); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int a = 0; a = 7 ? 5 : 1; printf("%d",a); return 0; }
A7
B5
C1
D0
सही उत्तर / Answer: (B)
हल / Solution
C में कोई भी non-zero मान सच (true) माना जाता है। a = 7 ? 5 : 1 में शर्त 7 है, जो non-zero है, इसलिए सच है। सच होने पर ?: का बीच वाला हिस्सा चुना जाता है, यानी a = 5। printf 5 छापता है। 7 शर्त का मान है, परिणाम नहीं। 1 तब आता जब शर्त झूठ यानी 0 होती। 0 a का पुराना मान है जो बदल चुका है।
In C, any non-zero value is treated as true. In a = 7 ? 5 : 1 the condition is 7, which is non-zero, so it is true. When the condition is true, the middle part of ?: is chosen, so a = 5. printf prints 5. The value 7 is the condition, not the result. 1 would be chosen only if the condition were 0, and 0 is the old value of a that was replaced.
प्रश्न 6उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int a=7; a = 0 ? 5 : 1; printf("%d",a); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int a=7; a = 0 ? 5 : 1; printf("%d",a); return 0; }
A7
B0
C5
D1
सही उत्तर / Answer: (D)
हल / Solution
C में 0 को झूठ (false) और हर non-zero मान को सच (true) माना जाता है। a = 0 ? 5 : 1 में शर्त सीधे 0 है, यानी झूठ। इसलिए तीसरा हिस्सा 1 चुना जाता है और a = 1 हो जाता है। printf 1 छापता है। 7 a का पुराना मान है जो बदल गया। 0 शर्त का मान है, परिणाम नहीं। 5 तब आता जब शर्त सच होती।
In C, 0 means false and every non-zero value means true. In a = 0 ? 5 : 1 the condition is the constant 0, which is false. So the third part, 1, is chosen and a becomes 1. printf prints 1. The value 7 is the old value of a that was overwritten. 0 is the condition itself, not the result, and 5 would be chosen only if the condition were true.
प्रश्न 7उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int a=0, b=10; a = (5>2) ? b=6: b; printf("%d %d",a, b); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int a=0, b=10; a = (5>2) ? b=6: b; printf("%d %d",a, b); return 0; }
A6 6
B8 8
C6 0
DCompile Time Error
सही उत्तर / Answer: (A)
हल / Solution
?: के बीच वाले हिस्से में कोई भी पूरा expression आ सकता है, इसलिए b=6 वहाँ ठीक है। तीसरा हिस्सा सिर्फ़ b है, इसलिए compile error नहीं आती। शर्त 5>2 सच है, तो बीच वाला हिस्सा चलता है: b = 6 होता है और उसी का मान 6 a को मिलता है। printf "6 6" छापता है। 8 8 और 6 0 इस क्रम से मेल नहीं खाते। error तब आती जब तीसरे हिस्से में भी assignment होता।
The middle part of ?: can hold any full expression, so b=6 is allowed there. The last part is just b, so there is no compile error. The condition 5>2 is true, so the middle part runs: b becomes 6, and the value 6 of that assignment is stored in a. printf prints "6 6". 8 8 and 6 0 do not match this flow, and an error would need an assignment in the last part too.
प्रश्न 8उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int a=0, b=10; a = (5>2) ? b=6: b=8; printf("%d %d",a, b); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int a=0, b=10; a = (5>2) ? b=6: b=8; printf("%d %d",a, b); return 0; }
A6 6
B8 8
C8 10
DCompile Time Error
सही उत्तर / Answer: (D)
हल / Solution
C में = की precedence ?: से कम है। इसलिए compiler इस पंक्ति को ऐसे पढ़ता है: a = (((5>2) ? b=6 : b) = 8)। यानी ?: के पूरे परिणाम में 8 assign करने की कोशिश होती है। C में ?: का परिणाम lvalue नहीं होता, उसमें कुछ assign नहीं हो सकता। इसलिए compiler 'lvalue required' जैसी error देकर रुक जाता है। 6 6, 8 8 या 8 10 तभी आते जब code compile हो पाता।
In C, = has lower precedence than ?:. So the compiler reads the line as a = (((5>2) ? b=6 : b) = 8). It tries to assign 8 to the result of the whole conditional expression. In C, the result of ?: is not an lvalue, so nothing can be assigned to it. The compiler stops with an error such as 'lvalue required'. Outputs like 6 6, 8 8 or 8 10 would need the code to compile.
प्रश्न 9उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { int a = 10; a = 5 < 2 ? 4 : 3; printf("%d",a); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { int a = 10; a = 5 < 2 ? 4 : 3; printf("%d",a); return 0; }
A4
B3
C10
D1
सही उत्तर / Answer: (B)
हल / Solution
conditional operator (?:) का रूप है: शर्त ? मान1 : मान2। शर्त सच हो तो मान1 मिलता है, झूठ हो तो मान2। यहाँ शर्त 5 < 2 है, जो झूठ है। इसलिए a को 3 मिलता है और पुराना मान 10 मिट जाता है। printf 3 छापता है। 4 तब आता जब शर्त सच होती। 10 पुराना मान है जो बदल चुका है, और 1 तुलना के परिणाम को ही उत्तर मानने की भूल है।
The conditional operator has the form condition ? value1 : value2. If the condition is true, value1 is used; otherwise value2 is used. Here the condition 5 < 2 is false, so a gets 3 and its old value 10 is overwritten. printf prints 3. The value 4 would appear only if the condition were true. 10 is the old value that was replaced, and 1 wrongly treats the result of the comparison as the answer.
प्रश्न 10उत्तर + हल
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { char ch[10] = {'a', 'e', 'i', 'o', 'u'}; printf("%d",sizeof(ch)); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { char ch[10] = {'a', 'e', 'i', 'o', 'u'}; printf("%d",sizeof(ch)); return 0; }
A1
B5
C6
D10
सही उत्तर / Answer: (D)
हल / Solution
यहाँ array का आकार साफ़ लिखा है — ch[10]। initializer में सिर्फ़ पाँच character हैं, बाक़ी पाँच जगहें अपने-आप 0 से भर जाती हैं। पर sizeof भरे हुए तत्व नहीं गिनता, वह घोषित आकार बताता है। 10 char × 1 byte = 10 byte, इसलिए output 10 है। 5 सिर्फ़ दिए गए character की गिनती है, 6 उसमें null जोड़कर गिनना है, और 1 सिर्फ़ एक char का आकार है।
Here the array size is written explicitly as ch[10]. The initializer gives only five characters, and the remaining five slots are filled with 0 automatically. But sizeof does not count the filled elements; it reports the declared size. So 10 chars × 1 byte = 10 bytes, and the output is 10. The value 5 counts only the given characters, 6 adds a null to that count, and 1 is the size of a single char.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { char ch[] = {'a', 'e', 'i', 'o', 'u'}; printf("%d",sizeof(ch[2])); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { char ch[] = {'a', 'e', 'i', 'o', 'u'}; printf("%d",sizeof(ch[2])); return 0; }
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> int main() { char ch[] = {'a', 'e', 'i', 'o', 'u'}; printf("%d",sizeof(ch)); return 0; }
What will be the output of following C language code? #include <stdio.h> int main() { char ch[] = {'a', 'e', 'i', 'o', 'u'}; printf("%d",sizeof(ch)); return 0; }
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> void main(){ printf("%d ", + +9); printf("%d ", + -9); printf("%d ", - +9); printf("%d ", - -9); }
What will be the output of the following C language code? #include <stdio.h> void main(){ printf("%d ", + +9); printf("%d ", + -9); printf("%d ", - +9); printf("%d ", - -9); }
निम्नलिखित C भाषा कोड का आउटपुट क्या होगा? #include <stdio.h> void main(){ int x=4, y, z; y = --x; z = x--; printf("%d %d %x", x, y, z); }
What will be the output of the following C language code? #include <stdio.h> void main(){ int x=4, y, z; y = --x; z = x--; printf("%d %d %x", x, y, z); }