पहले 10 प्रश्नों के उत्तर और हल यहीं खुले हैं; बाक़ी 20 के उत्तर और हल FliQi Question Bank app में।
भाषा
प्रश्न 1उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i, j;
for(i = 1;i<=5;i++){
for(j = 1;j<=5;j++){
if(i == j)
continue;
printf("FliQi ");
}
}
return 0;
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i, j;
for(i = 1;i<=5;i++){
for(j = 1;j<=5;j++){
if(i == j)
continue;
printf("FliQi ");
}
}
return 0;
}
AFliQi को 24 बार प्रिंट किया जाएगाFliQi will be printed 24 times
BFliQi को 25 बार प्रिंट किया जाएगाFliQi will be printed 25 times
CFliQi को 20 बार प्रिंट किया जाएगाFliQi will be printed 20 times
DFliQi को 21 बार प्रिंट किया जाएगाFliQi will be printed 21 times
सही उत्तर / Answer: (C)
हल / Solution
दोनों लूप 1 से 5 तक चलते हैं, इसलिए कुल 5 × 5 = 25 जोड़े बनते हैं। जब i और j बराबर होते हैं, तब continue चलता है और printf छूट जाता है। ऐसे जोड़े 5 हैं: (1,1), (2,2), (3,3), (4,4), (5,5)। इसलिए FliQi 25 − 5 = 20 बार छपता है। continue सिर्फ़ अंदर वाले लूप की मौजूदा बारी छोड़ता है, लूप नहीं तोड़ता।
Both loops run from 1 to 5, so there are 5 × 5 = 25 pairs in all. When i equals j, continue runs and the printf is skipped. There are 5 such pairs: (1,1), (2,2), (3,3), (4,4) and (5,5). So FliQi is printed 25 − 5 = 20 times. continue only skips the current pass of the inner loop; it does not end the loop.
प्रश्न 2उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
if(i!=5){
continue;
}
printf("FliQi ");
}
return 0;
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
if(i!=5){
continue;
}
printf("FliQi ");
}
return 0;
}
AFliQi को 1 बार प्रिंट किया जाएगाFliQi will be printed 1 times
BFliQi को 9 बार प्रिंट किया जाएगाFliQi will be printed 9 times
CFliQi को 10 बार प्रिंट किया जाएगाFliQi will be printed 10 times
DFliQi को 0 बार प्रिंट किया जाएगाFliQi will be printed 0 times
सही उत्तर / Answer: (A)
हल / Solution
जब i 5 नहीं होता, तब continue चलता है और printf छूट जाता है। यानी i = 1 से 4 और 6 से 10 तक, कुल 9 बारियों में कुछ नहीं छपता। सिर्फ़ i = 5 पर शर्त i != 5 झूठी होती है, continue नहीं चलता और FliQi छपता है। इसलिए FliQi केवल 1 बार छपता है। 9 बार वाला विकल्प छूटी हुई बारियों को गिनता है।
Whenever i is not 5, continue runs and the printf is skipped. So for i = 1 to 4 and 6 to 10, nine passes in all, nothing is printed. Only at i = 5 is the condition i != 5 false, so continue does not run and FliQi is printed. So FliQi is printed just 1 time. The 9 times option counts the skipped passes instead.
प्रश्न 3उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
printf("FliQi ");
if(i==5){
break;
continue;
}
}
return 0;
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
printf("FliQi ");
if(i==5){
break;
continue;
}
}
return 0;
}
AFliQi को 4 बार प्रिंट किया जाएगाFliQi will be printed 4 times
BFliQi को 9 बार प्रिंट किया जाएगाFliQi will be printed 9 times
CFliQi को 5 बार प्रिंट किया जाएगाFliQi will be printed 5 times
DFliQi को 7 बार प्रिंट किया जाएगाFliQi will be printed 7 times
सही उत्तर / Answer: (C)
हल / Solution
हर बारी में पहले FliQi छपता है, फिर if (i == 5) जाँचा जाता है। i = 1 से 4 तक शर्त झूठी है, इसलिए लूप चलता रहता है और FliQi चार बार छपता है। i = 5 पर पहले FliQi पाँचवीं बार छपता है, फिर break लूप तोड़ देता है। break के नीचे लिखा continue कभी नहीं चलता। इसलिए FliQi कुल 5 बार छपता है, 4 बार नहीं।
In each pass FliQi is printed first, and then if (i == 5) is checked. For i = 1 to 4 the condition is false, so the loop continues and FliQi is printed four times. At i = 5, FliQi is printed a fifth time and then break ends the loop. The continue below break never runs. So FliQi is printed 5 times in total.
प्रश्न 4उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int a = 5;
if(a!=5){
printf("FliQi");
break;
}
else{
printf("FliQi India");
}
return 0;
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int a = 5;
if(a!=5){
printf("FliQi");
break;
}
else{
printf("FliQi India");
}
return 0;
}
AFliQi
BFliQi India
Cकुछ भी प्रिंट नहींPrint Nothing
Dकंपाइल टाइम एररCompile Time Error
सही उत्तर / Answer: (D)
हल / Solution
यहाँ break एक if के अंदर है और पूरे main में कोई लूप या switch नहीं है। C में break सिर्फ़ लूप या switch के अंदर ही लिखा जा सकता है। यह नियम कंपाइल के समय जाँचा जाता है, इसलिए शर्त a != 5 झूठी होने से कोई फ़र्क़ नहीं पड़ता। कंपाइलर error देता है और प्रोग्राम बनता ही नहीं। इसलिए FliQi India भी नहीं छपता।
Here break is inside an if, and there is no loop or switch anywhere in main. In C, break may be written only inside a loop or a switch. This rule is checked at compile time, so it does not matter that the condition a != 5 is false. The compiler reports an error and the program is never built. So even FliQi India is not printed.
प्रश्न 5उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
if(i==5){
printf("FliQi");
}
break;
}
return 0;
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
if(i==5){
printf("FliQi");
}
break;
}
return 0;
}
AFliQi
BFliQi को 9 बार प्रिंट किया जाएगाFliQi will be printed 9 times
CFliQi को 10 बार प्रिंट किया जाएगाFliQi will be printed 10 times
DFliQi को 0 बार प्रिंट किया जाएगाFliQi will be printed 0 times
सही उत्तर / Answer: (D)
हल / Solution
ध्यान दीजिए कि break if के कोष्ठक के बाहर है, यानी यह हर बारी में चलता है। पहली बारी में i = 1 है। शर्त i == 5 झूठी है, इसलिए FliQi नहीं छपता। उसके तुरंत बाद break चलता है और लूप वहीं ख़त्म हो जाता है। i कभी 5 तक पहुँचता ही नहीं। इसलिए FliQi एक बार भी नहीं छपता, यानी 0 बार। 9 या 10 बार छपने का सवाल ही नहीं उठता।
Notice that break is outside the braces of the if, so it runs in every pass. In the first pass i is 1. The condition i == 5 is false, so FliQi is not printed. Right after that, break runs and the loop ends there. i never reaches 5. So FliQi is not printed even once, that is 0 times. Printing it 9 or 10 times is not possible.
प्रश्न 6उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
if(i%2==0){
continue;
}
printf("%d ",i);
}
return 0;
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i;
for(i = 1;i<=10;i++){
if(i%2==0){
continue;
}
printf("%d ",i);
}
return 0;
}
A2 4 6 8 10
B1 3 5 7 9
Cकंपाइल टाइम एररCompile Time Error
Dकुछ भी प्रिंट नहींPrint Nothing
सही उत्तर / Answer: (B)
हल / Solution
लूप i = 1 से 10 तक चलता है। जब i सम होता है, यानी i%2 == 0, तब continue चलता है और printf छूट जाता है। विषम i पर शर्त झूठी रहती है, इसलिए वही संख्या छपती है। इस तरह सिर्फ़ 1, 3, 5, 7 और 9 छपते हैं। 2 4 6 8 10 उलटा उत्तर है, जो तब मिलता जब विषम संख्याएँ छोड़ी जातीं। कोड में कोई error नहीं है।
The loop runs for i = 1 to 10. When i is even, that is i%2 == 0, continue runs and the printf is skipped. For odd i the condition is false, so that number is printed. So only 1, 3, 5, 7 and 9 are printed. 2 4 6 8 10 is the opposite result, which would come if odd numbers were skipped. The code has no error.
प्रश्न 7उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i;
for(;;);{
printf("FliQi");
break;
}
return 0;
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i;
for(;;);{
printf("FliQi");
break;
}
return 0;
}
AFliQi
Bअनंत लूपInfinite Loop
Cकंपाइल टाइम एररCompile Time Error
Dकुछ भी प्रिंट नहींPrint Nothing
सही उत्तर / Answer: (C)
हल / Solution
for(;;); के अंत में लगा सेमीकॉलन ध्यान दीजिए। यही सेमीकॉलन लूप की पूरी body है, यानी एक ख़ाली statement। नीचे वाला { } ब्लॉक लूप का हिस्सा नहीं, एक अलग ब्लॉक है। उस ब्लॉक में लिखा break अब किसी लूप या switch के अंदर नहीं है, इसलिए कंपाइलर error देता है। प्रोग्राम कंपाइल ही नहीं होता। यह error न होती तो for(;;); अनंत लूप बनता।
Notice the semicolon at the end of for(;;); . That semicolon is the whole loop body, an empty statement. The { } block below is not part of the loop; it is a separate block. The break inside that block is no longer inside any loop or switch, so the compiler reports an error. The program does not compile. Without that error, for(;;); would have been an infinite loop.
प्रश्न 8उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
printf("before continue ");
continue;
printf("after continue\n");
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
printf("before continue ");
continue;
printf("after continue\n");
}
ABefore continue after continue
BBefore continue
CAfter continue
Dकंपाइल टाइम एररCompile time error
सही उत्तर / Answer: (D)
हल / Solution
continue का काम लूप की अगली बारी पर भेजना है, इसलिए यह सिर्फ़ लूप के अंदर ही लिखा जा सकता है। यहाँ continue सीधे main के अंदर है, कोई लूप है ही नहीं। कंपाइलर इसे ग़लत मानकर error देता है। प्रोग्राम कंपाइल नहीं होता, इसलिए कोई भी printf नहीं चलता। पहला printf भी नहीं चलता, क्योंकि error चलाने से पहले, कंपाइल के समय ही आ जाती है।
continue sends control to the next pass of a loop, so it can be written only inside a loop. Here continue is placed directly in main, with no loop at all. The compiler treats this as an error. Since the program does not compile, no printf runs. Even the first printf does not run, because the error appears at compile time, before the program can ever execute.
प्रश्न 9उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i = 0;
while(i < 2){
if(i == 1)
break;
i++;
if(i == 1)
continue;
printf("In while loop ");
}
printf("After loop ");
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i = 0;
while(i < 2){
if(i == 1)
break;
i++;
if(i == 1)
continue;
printf("In while loop ");
}
printf("After loop ");
}
AIn while loop After loop
BAfter loop
CIn while loop In while loop After loop
DIn while loop
सही उत्तर / Answer: (B)
हल / Solution
पहली बारी में i = 0 है, इसलिए पहला if झूठा है। फिर i++ से i 1 होता है और दूसरा if सच हो जाता है, तो continue printf को छोड़कर शर्त पर भेज देता है। दूसरी बारी में i = 1 है, इसलिए पहला if सच है और break लूप तोड़ देता है। In while loop एक बार भी नहीं छपता। लूप के बाद केवल After loop छपता है।
In the first pass i is 0, so the first if is false. Then i++ makes i equal to 1, the second if is true, and continue skips the printf and goes back to the condition. In the second pass i is 1, so the first if is true and break ends the loop. In while loop is never printed. After the loop, only After loop is printed.
प्रश्न 10उत्तर + हल
निम्नलिखित C कोड का आउटपुट क्या होगा?
#include <stdio.h>
int main(){
int i = 0, j = 0;
for (i; i < 2; i++){
for (j = 0; j < 3; j++){
printf("1 ");
break;
}
printf("2 ");
}
printf("after loop ");
}
What will be the output of the following C code?
#include <stdio.h>
int main(){
int i = 0, j = 0;
for (i; i < 2; i++){
for (j = 0; j < 3; j++){
printf("1 ");
break;
}
printf("2 ");
}
printf("after loop ");
}
A1 2 after loop
B1 after loop
C1 2 1 2 after loop
D1 1 2 after loop
सही उत्तर / Answer: (C)
हल / Solution
बाहरी लूप i = 0 और i = 1 के लिए दो बार चलता है। हर बार अंदर वाला लूप शुरू होते ही 1 छापता है और तुरंत break चलता है। यह break सिर्फ़ अंदर वाले लूप को तोड़ता है, बाहरी लूप चलता रहता है। फिर 2 छपता है। इस तरह 1 2 दो बार छपता है। अंत में after loop छपता है। इसलिए आउटपुट 1 2 1 2 after loop है। break पूरे प्रोग्राम के लूप नहीं तोड़ता।
The outer loop runs twice, for i = 0 and i = 1. Each time, the inner loop prints 1 and then break runs at once. This break ends only the inner loop; the outer loop keeps going. Then 2 is printed. So 1 2 appears twice. At the end after loop is printed. The output is 1 2 1 2 after loop. A break never ends every loop at once, only the nearest one.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
जंप स्टेटमेंट के बारे में निम्नलिखित में से कौन सा कथन असत्य है?
Which of the following statement is false about jump statements?
Aहम लूप या स्विच स्टेटमेंट के बाहर ब्रेक जम्प स्टेटमेंट नहीं लिख सकते हैं।We cannot write break jump statement outside loop or switch statement
Bयदि इनर लूप में ब्रेक स्टेटमेंट लिखा जाता है तो इनर लूप ही टर्मिनेट होगा।If break statement is written in inner loop then inner loop will terminate only
Cgoto जंप स्टेटमेंट और उसके लेबल को एक ही फंक्शन में डिक्लेअर किया जाना चाहिए।The goto jump statement and its label must be declared in the same function
Dरिटर्न जंप स्टेटमेंट इसे समाप्त करने के बाद कॉलर फ़ंक्शन पर नियंत्रण वापस नहीं करता है।The return jump statement does not return the control to the caller function after terminating it