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

Control Statements in C Language — प्रश्न और उत्तर

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

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

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

भाषा
प्रश्न 1उत्तर + हल
निम्नलिखित में से कौन सा C कथन वाक्य-रचना की दृष्टि से सही है?
Which of the following C statement is syntactically correct?
  1. Afor (;;);
  2. Bfor (;);
  3. Cfor ();
  4. Dfor (.);

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

हल / Solution
for की वाक्य-रचना में कोष्ठक के भीतर ठीक दो अर्ध-विराम चाहिए, क्योंकि वे तीन खानों को अलग करते हैं — शुरुआत, शर्त और वृद्धि। खाने ख़ाली छोड़े जा सकते हैं, पर अर्ध-विराम नहीं छोड़े जा सकते। इसी से पहला रूप पूरी तरह वैध है और वह अनंत लूप बनाता है। दूसरे में एक अर्ध-विराम कम है, तीसरे में एक भी नहीं, और चौथे में बिंदु का कोई अर्थ नहीं — तीनों पर कंपाइलर त्रुटि देता है।
The syntax of for needs exactly two semicolons inside the parentheses, because they separate the three slots: initialisation, condition and increment. The slots themselves may be left empty, but the semicolons may not be dropped. That is why the first form is perfectly legal and builds an endless loop. The second has one semicolon too few, the third has none, and a lone dot in the fourth means nothing, so all three fail to compile.
प्रश्न 2उत्तर + हल
स्विच (switch) कथन का उपयोग किया जाता है —
A switch statement is used to
  1. Aस्विचिंग चर (switching variable) के उपयोग के लिएTo use switching variable
  2. Bप्रोग्राम में एक फंक्शन से दूसरे फंक्शन पर स्विच करने के लिएSwitch between functions in a program
  3. Cएक चर से दूसरे चर पर स्विच करने के लिएSwitch from one variable to another variable
  4. Dकिसी एक चर के अलग-अलग मानों से बनने वाली कई संभावनाओं में से चुनने के लिएTo choose from multiple possibilities which may arise due to different values of a variable

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

हल / Solution
switch एक व्यंजक का मान लेकर उसे एक-एक case लेबल से मिलाता है और जहाँ मेल बैठे वहीं से चलना शुरू कर देता है। यानी इसका काम किसी एक चर के अलग-अलग मानों से बनी कई संभावनाओं में से एक चुनना है — इसे बहु-शाखा चुनाव (multi-way branching) कहते हैं। नाम में «स्विच» होने से यह चर बदलता नहीं, और फंक्शनों के बीच कूदना भी इसका काम नहीं। इसीलिए चौथा विकल्प सही है।
A switch takes the value of one expression, matches it against the case labels one by one and starts running from the label that matches. Its job is therefore to choose among the several possibilities created by the different values of a single variable, which is called multi-way branching. The word switch in its name does not mean it swaps variables, and jumping between functions is not its work either, so the fourth option is right.
प्रश्न 3उत्तर + हल
CONTINUE कथन का उपयोग किसके साथ नहीं किया जा सकता?
The CONTINUE statement cannot be used with
  1. Afor
  2. Bswitch
  3. Cdo While
  4. Dwhile

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

हल / Solution
continue का अर्थ है «लूप का बचा हिस्सा छोड़ो और अगला चक्कर शुरू करो», इसलिए वह सिर्फ़ for, while और do-while में अर्थ रखता है। switch में चक्कर जैसा कुछ होता ही नहीं, सो अकेले switch के शरीर में continue लिखने पर कंपाइलर त्रुटि देता है। हाँ, switch किसी लूप के भीतर पड़ा हो तो वहाँ लिखा continue भीतर के switch को छोड़कर उस लूप पर असर डालता है। switch से बाहर निकलने का कथन break है।
continue means skip the rest of the loop body and start the next pass, so it only makes sense inside for, while and do-while. A switch has no passes of its own, so writing continue in a bare switch body is a compile error. If that switch happens to sit inside a loop, then continue applies to the loop and simply leaves the switch behind. The statement meant for leaving a switch is break.
प्रश्न 4उत्तर + हल
निम्नलिखित लूप कब तक चलेगा?

for (x=0; x=3; x++)
How long does the following loop last?

for (x=0; x=3; x++)
  1. Aतीन बारthree times
  2. Bचार बारfour times
  3. Cहमेशाforever
  4. Dकभी नहींNever

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

हल / Solution
यहाँ शर्त के खाने में तुलना x == 3 नहीं, बल्कि निर्धारण (assignment) x = 3 लिखा है। C में निर्धारण का अपना मान वही होता है जो दाहिनी ओर रखा गया है, यानी तीन, और शून्य से अलग हर मान सच गिना जाता है। इसलिए शर्त हर चक्कर में सच मिलती है और लूप कभी नहीं रुकता। x++ चलता रहता है पर शर्त उसे देखती ही नहीं, सो तीन या चार बार वाले विकल्प ग़लत हैं।
The condition slot does not hold the comparison x == 3 but the assignment x = 3. In C an assignment itself has a value, namely the value placed on its right, which is three here, and every value other than zero counts as true. So the condition is true on every pass and the loop never stops. x++ keeps running but the condition never looks at it, which rules out three times, four times and never.
प्रश्न 5उत्तर + हल
SWITCH कथन के नियंत्रक कथन (controlling statement) का डेटा प्रकार किस प्रकार का नहीं हो सकता?
Data type of the controlling statement of a SWITCH statement cannot be of the type:
  1. Aint
  2. Bchar
  3. Cshort
  4. Dfloat

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

हल / Solution
switch जिस व्यंजक पर चलता है वह पूर्णांक जाति (integral type) का होना ज़रूरी है — int, short, long, char या enum। char भी भीतर से छोटा पूर्णांक ही है, सो वह चलता है। float और double दशमलव वाले प्रकार हैं और उनमें बराबरी की जाँच भरोसेमंद नहीं होती, इसलिए C मानक उन्हें switch में मना करता है और कंपाइलर साफ़ त्रुटि देता है। इसी कारण यहाँ सही उत्तर float है।
The expression a switch runs on must be of an integral type: int, short, long, char or an enum. A char is itself a small integer inside, so it is allowed. float and double are fractional types and equality testing on them is never reliable, so the C standard does not permit them in a switch and the compiler reports a clear error. That is why float is the answer here.
प्रश्न 6उत्तर + हल
_______ में दो लूपों के शरीर को मिलाकर एक लूप बना दिया जाता है, बशर्ते वे एक-दूसरे को ही संदर्भित न कर रहे हों।
In _______, the bodies of the two loops are merged together to form a single loop provided that they do not make only references to each other.
  1. ALoop unrolling
  2. BStrength reduction
  3. CLoop concatenation
  4. DLoop jamming

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

हल / Solution
एक ही सीमा पर चलने वाले दो अलग लूपों को जोड़कर एक लूप बना देना «लूप जैमिंग» (loop jamming) कहलाता है; इसे लूप फ्यूज़न भी कहते हैं और इससे लूप का ऊपरी ख़र्च घटता है। लूप अनरोलिंग (loop unrolling) में शरीर की नक़लें बनाकर चक्करों की गिनती घटाई जाती है। स्ट्रेंथ रिडक्शन (strength reduction) में महँगी गुणा की जगह सस्ता जोड़ रखा जाता है। «लूप कंकैटिनेशन» कोई मानक अनुकूलन ही नहीं है।
Merging two separate loops that run over the same range into a single loop is called loop jamming, also known as loop fusion; it cuts down the overhead of running the loop twice. Loop unrolling instead copies the body so that fewer passes are needed. Strength reduction replaces a costly multiplication with cheaper addition. Loop concatenation is not a standard optimisation name at all, so it only works as a distractor here.
प्रश्न 7उत्तर + हल
C में «break» तथा «continue» कथनों के संदर्भ में सबसे सही कथन चुनिए।
In the context of "break" and "continue" statements in C, pick the best statement.
  1. A«break» और «continue» दोनों for, while, do-while के शरीर में तथा switch के शरीर में चल सकते हैं"break" and "continue" can be used in "for", "while", "do-while" loop body and "switch" body
  2. B«break» और «continue» दोनों for, while, do-while के शरीर में चल सकते हैं, पर switch के शरीर में सिर्फ़ «break» चल सकता है"break" and "continue" can be used in "for", "while", "do-while" loop body but only "break" can be used in "switch" body
  3. C«break» और «continue» for, while तथा do-while के शरीर में चल सकते हैं, और इनके अलावा «continue» तथा «break» switch एवं «if-else» के शरीर में भी चल सकते हैं"break" and "continue" can be used in "for", "while" and "do-while" loop body besides, "continue" and "break" can be used in "switch" and "if-else" body
  4. D«break» for, while तथा do-while के शरीर में चल सकता है"break" can be used in "for", "while" and "do-while" loop body

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

हल / Solution
break तीनों लूप — for, while, do-while — और switch, चारों जगह चलता है; switch में वही एक-एक case को अलग करता है। continue का काम है «बचा हिस्सा छोड़कर अगला चक्कर शुरू करो», जो सिर्फ़ लूप में अर्थ रखता है, सो अकेले switch के शरीर में लिखने पर कंपाइलर त्रुटि देता है। इसी से दूसरा विकल्प सही है। पहला continue को switch में भी जायज़ बताता है और चौथा continue छोड़ ही देता है।
break works in all three loops, for, while and do-while, and in switch as well, where it separates one case from the next. continue means skip the rest of this pass and start the next one, which makes sense only inside a loop, so writing it in a bare switch body is a compile error. That makes the second option right. The first allows continue in switch, the third adds if-else, and the fourth drops continue altogether.
प्रश्न 8उत्तर + हल
इस C कोड का आउटपुट क्या है?

int main()

{

int i = 0, j = 0;

while (i < 5, j < 10)

{

 i++;

j++;

}

printf("%d, %d\n", i, j);

}
What is the output of this C code?

int main()

{

int i = 0, j = 0;

while (i < 5, j < 10)

{

 i++;

j++;

}

printf("%d, %d\n", i, j);

}
  1. A5, 5
  2. B5, 10
  3. C10, 10
  4. DSyntax error

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

हल / Solution
while की शर्त में अल्पविराम संचालक (comma operator) लगा है। यह संचालक बाएँ भाग को जाँचकर उसका नतीजा फेंक देता है और पूरे व्यंजक का मान सिर्फ़ दाहिने भाग से तय होता है, यानी यहाँ शर्त केवल j < 10 है। इसलिए i < 5 का कोई असर नहीं पड़ता और लूप j के दस होने तक चलता है; साथ-साथ i भी दस तक बढ़ जाता है। छपाई «10, 10» आती है और वाक्य-रचना वैध है।
The while condition uses the comma operator. It evaluates the left part, throws that result away, and the value of the whole expression comes only from the right part, so the real condition here is just j < 10. The test i < 5 therefore has no effect, the loop runs until j reaches ten, and i climbs to ten alongside it. The output is 10, 10 and the syntax is perfectly legal.
प्रश्न 9उत्तर + हल
C में पुनरावृत्ति (iteration) का उदाहरण है —
Example of iteration in C.
  1. Afor
  2. Bwhile
  3. Cdo-while
  4. Dउपरोक्त सभीAll of the mentioned

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

हल / Solution
पुनरावृत्ति (iteration) का अर्थ है एक ही कथन-समूह को बार-बार चलाना, और C में इसके तीन रूप हैं — for, while तथा do-while। for तब सुविधा देता है जब चक्कर की गिनती पहले से तय हो। while शर्त पहले जाँचता है, इसलिए शरीर शून्य बार भी चल सकता है। do-while शरीर एक बार चलाकर बाद में शर्त देखता है, सो वह कम-से-कम एक बार चलता ही है। तीनों लूप हैं, इसलिए «उपरोक्त सभी» सही है।
Iteration means running the same group of statements again and again, and C offers three forms of it: for, while and do-while. A for loop suits the case where the number of passes is known in advance. A while loop tests its condition first, so the body may run zero times. A do-while loop runs the body once and tests afterwards, so it always runs at least once. All three are loops, so All of the mentioned is right.
प्रश्न 10उत्तर + हल
इस प्रोग्राम का आउटपुट क्या है?

int main() {

int i;

for ( i=0; i<5; i++ )

{

i = 10;

printf ( "%d ", i );

}

return 0;

}
What is the output of this program?

int main() {

int i;

for ( i=0; i<5; i++ )

{

i = 10;

printf ( "%d ", i );

}

return 0;

}
  1. A10 10 10 10 10
  2. B10 11 12 13
  3. C10
  4. DCompilation Error

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

हल / Solution
पहले चक्कर में i शून्य है, पर लूप के भीतर पहुँचते ही उसे दस कर दिया जाता है, सो printf दस छापता है। चक्कर पूरा होने पर i++ चलता है और i ग्यारह हो जाता है; अब शर्त i < 5 झूठी पड़ जाती है और लूप वहीं रुक जाता है। यानी छपाई एक ही बार होती है। पाँच बार या बढ़ती गिनती वाले विकल्प तभी बनते जब भीतर मान बदला न जाता।
On the first pass i is zero, but the body immediately sets it to ten, so printf prints ten. At the end of the pass i++ makes i eleven, the condition i < 5 now fails and the loop stops there. So the printing happens only once. The repeated row and the increasing sequence would appear only if the body did not overwrite i, and the code itself compiles without any error.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 12उत्तर app में
इस C कोड का आउटपुट क्या है?

void main()

{

int i = 0;

int j = 0;

for (i = 0;i < 5; i++)

{

for (j = 0;j < 4; j++)

{

if (i > 1)

continue;

printf("Hi \n");

}

}

}
What is the output of this C code?

void main()

{

int i = 0;

int j = 0;

for (i = 0;i < 5; i++)

{

for (j = 0;j < 4; j++)

{

if (i > 1)

continue;

printf("Hi \n");

}

}

}
  1. AHi नौ बार छपेगाHi is printed 9 times
  2. BHi आठ बार छपेगाHi is printed 8 times
  3. CHi सात बार छपेगाHi is printed 7 times
  4. DHi छह बार छपेगाHi is printed 6 times
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में
इस C कोड का आउटपुट क्या है?

int main()

{

int a=5;

while(a==5)    

{

printf("RABBIT");

break;

}

return 0;

}
What is the output of this C Program?

int main()

{

int a=5;

while(a==5)    

{

printf("RABBIT");

break;

}

return 0;

}
  1. ARABBIT अनंत बार छपेगाRABBIT is printed unlimited number of times
  2. BRABBIT
  3. CCompiler error
  4. Dउपरोक्त में से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
for लूप के संबंध में सही C कथन चुनिए।

for(; ;);
Choose a correct C Statement regarding for loop.

for(; ;);
  1. Afor लूप ठीक पहली बार ही चलता हैfor loop works exactly first time
  2. Bfor लूप अनंत बार चलता हैfor loop works infinite number of times
  3. CCompiler error
  4. Dउपरोक्त में से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में
निम्नलिखित C कोड का आउटपुट क्या होगा?

void main()

{

int i = 0;

for (i = 0;i < 5; i++)

if (i < 4)

{

printf("Hello");

break;

}

}
What will be the output of the following C code?

void main()

{

int i = 0;

for (i = 0;i < 5; i++)

if (i < 4)

{

printf("Hello");

break;

}

}
  1. AHello पाँच बार छपेगाHello is printed 5 times
  2. BHello चार बार छपेगाHello is printed 4 times
  3. CHello
  4. DHello तीन बार छपेगाHello is printed 3 times
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
निम्नलिखित C कोड का आउटपुट क्या होगा?

enum fliqi

 {

c = 0,

d = 10,

h = 20,

s = 3

} a;

int main()

{

printf("Size of enum variable = %d bytes", sizeof(a));

return 0;

}
What will be the output of the following C code?

enum fliqi

 {

c = 0,

d = 10,

h = 20,

s = 3

} a;

int main()

{

printf("Size of enum variable = %d bytes", sizeof(a));

return 0;

}
  1. AError
  2. BSize of enum variable = 16 bytes
  3. CSize of enum variable = 4 bytes
  4. DSize of enum variables = 8 bytes
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
नीचे दिए गए कोड का आउटपुट क्या है?

void main()

{

int i = 0, k;

label: printf("%d", i);

if (i == 0)

goto label;

}
What is the output of the code below?

void main()

{

int i = 0, k;

label: printf("%d", i);

if (i == 0)

goto label;

}
  1. A0
  2. Bअनंत बार 0Infinite 0
  3. Cकुछ नहींNothing
  4. Dत्रुटिError
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में
switch कथन वाले इस C प्रोग्राम का आउटपुट क्या है?

int main()

{

int a;

switch(a);

{

printf("DEER ");

}

printf("LION");

}
What is the output of this C program with a switch statement?

int main()

{

int a;

switch(a);

{

printf("DEER ");

}

printf("LION");

}
  1. ALION
  2. BDEER LION
  3. CCompiler त्रुटिCompiler Error
  4. Dइनमें से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 21उत्तर app में
इस C कोड का आउटपुट क्या है?

int main()

{

printf("before continue ");

continue;

printf("after continue\n");

}
What is the output of this C code?

int main()

{

printf("before continue ");

continue;

printf("after continue\n");

}
  1. ABefore continue after continue
  2. BBefore continue
  3. Cafter continue
  4. DCompile time त्रुटिCompile time error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 22उत्तर app में
इस C कोड का आउटपुट क्या है?

void main()

{

int i = 0;

if (i == 0)

{

printf("Hello");

break;

}

}
What is the output of this C code?

void main()

{

int i = 0;

if (i == 0)

{

printf("Hello");

break;

}

}
  1. AHello अनंत बार छपेगाHello is printed infinite times
  2. BHello
  3. Cबदलता रहता हैvaries
  4. DCompile time त्रुटिcompile time error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 24उत्तर app में
switch कथन वाले इस C प्रोग्राम का आउटपुट क्या है?

int main()

{

int a=3;

switch(a)

{

}

printf("fliqi");

}
What is the output of this C program with a switch statement?

int main()

{

int a=3;

switch(a)

{

}

printf("fliqi");

}
  1. Afliqi
  2. Bकोई आउटपुट नहींNo Output
  3. CCompiler त्रुटिCompiler Error
  4. Dइनमें से कोई नहींNone of the above
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 25उत्तर app में
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

int main()

{

for(int j = 1; j <= 10; j = j)

{

printf("%d\n",j);

break;

}

return 0;

}
What will be the output of the following?

int main()

{

for(int j = 1; j <= 10; j = j)

{

printf("%d\n",j);

break;

}

return 0;

}
  1. Aहमेशा चलता रहेगाForever
  2. Bकभी नहींNever
  3. C0
  4. D1
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 27उत्तर app में
C, प्रोग्राम में एक बिंदु से दूसरे बिंदु पर बिना शर्त जाने (branch) के लिए ______ कथन का समर्थन करता है।
C supports the ______ statement to branch unconditionally from one point to another in the program.
  1. Acontinue
  2. Bgoto
  3. Cbreak
  4. Dfor
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 28उत्तर app में
एक "switch" कथन का उपयोग किसलिए किया जाता है?
A "switch" statement is used to:
  1. Aप्रोग्राम में user-defined फ़ंक्शनों के बीच बदलने के लिएSwitch between user defined functions in a program
  2. Bएक चर (variable) से दूसरे चर पर जाने के लिएSwitch from one variable to another variable
  3. Cप्रोग्राम में एक जगह से दूसरी जगह कूदने के लिएJump from one place to another in a program.
  4. Dइनमें से कोई नहींNone of these
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 29उत्तर app में
continue कथन का उपयोग किया जाता है:
The continue statement is used:
  1. Aलूप में अगले चक्कर (iteration) पर जाने के लिएto go to the next iteration in a loop
  2. Bलूप से बाहर आने के लिएcome out of a loop
  3. Cबाहर निकलकर main फ़ंक्शन में लौटने के लिएexit and return to the main function
  4. Dलूप के चक्कर फिर से शुरू से चलाने के लिएrestarts iterations from beginning of loop
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Control Statements in C Language के सभी 106 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

C Language के दूसरे topics

सभी topics