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

Switch Case in C Language — प्रश्न और उत्तर

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

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

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

भाषा
प्रश्न 1उत्तर + हल
नीचे दिए गए प्रोग्राम का आउटपुट बताइए।

#include <stdio.h>

#define EVEN 0

#define ODD 1

int main()

{

    int i = 3;

    switch (i & 1)

    {

        case EVEN: printf("Even");

                break;

        case ODD: printf("Odd");

                break;

        default: printf("Default");

    }

    return 0;

}
Predict the output of the below program.

#include <stdio.h>

#define EVEN 0

#define ODD 1

int main()

{

    int i = 3;

    switch (i & 1)

    {

        case EVEN: printf("Even");

                break;

        case ODD: printf("Odd");

                break;

        default: printf("Default");

    }

    return 0;

}
  1. AEven
  2. BOdd
  3. CDefault
  4. DCompile-time error

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

हल / Solution
i का मान 3 है और यहाँ बिटवार AND (bitwise AND) लगाया गया है। 3 का द्विआधारी रूप 11 है और 1 का 01; दोनों का AND 01 यानी 1 निकलता है। #define से ODD का अर्थ 1 है, इसलिए switch उसी लेबल पर पहुँचता है, Odd छापता है और break से बाहर आ जाता है। यह तरकीब सम-विषम जाँचने का तेज़ तरीक़ा है — आख़िरी बिट 1 हुआ तो संख्या विषम। इसलिए Even या Default नहीं आता।
The value of i is 3, and a bitwise AND is applied here. In binary 3 is 11 and 1 is 01, so their AND gives 01, that is 1. The #define makes ODD stand for 1, so the switch reaches that label, prints Odd and leaves through break. This trick is a fast way of testing whether a number is odd.
प्रश्न 2उत्तर + हल
नीचे दिए गए प्रोग्राम का आउटपुट क्या है?

#include <stdio.h>

int main()

{

    int i = 0;

    switch (i)

    {

        case '0': printf("FliQi");

                break;

        case '1': printf("India");

                break;

        default: printf("FliQi India");

    }

    return 0;

}
What is the output of the below program?

#include <stdio.h>

int main()

{

    int i = 0;

    switch (i)

    {

        case '0': printf("FliQi");

                break;

        case '1': printf("India");

                break;

        default: printf("FliQi India");

    }

    return 0;

}
  1. AFliQi
  2. BIndia
  3. CFliQi India
  4. DCompile-time error

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

हल / Solution
लेबल में लिखे अक्षर कैरेक्टर स्थिरांक (character constant) हैं, और C उन्हें उनके ASCII मान से लेता है — यानी 48 और 49। switch में i का मान शून्य है, जो न 48 से मिलता है और न 49 से। कोई case न मिलने पर नियंत्रण default में जाता है, इसलिए FliQi India छपता है। अकेला FliQi पाने के लिए लेबल case 0 होता या i में वह अक्षर रखा जाता। कोड वैध है, सो एरर नहीं आता।
The characters written in the labels are character constants, and C takes them by their ASCII values, that is 48 and 49. In the switch the value of i is zero, which matches neither 48 nor 49. When no case label matches, control goes to the default label, so FliQi India is printed. To get FliQi alone the label would have to be case 0.
प्रश्न 3उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    int a = 0;

    switch(a)

    {

             case 0:

                       printf("Delhi");

                       break;

              case 3<5:

                   printf("Jaipur");

                       break;

              case 5<3:

                   printf("Gurugram");

    }

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

#include <stdio.h>

int main(){

    int a = 0;

    switch(a)

    {

             case 0:

                       printf("Delhi");

                       break;

              case 3<5:

                   printf("Jaipur");

                       break;

              case 5<3:

                   printf("Gurugram");

    }

}
  1. ADelhi
  2. BDelhi Gurugram
  3. CJaipur
  4. DCompile Time Error

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

हल / Solution
case के आगे स्थिरांक अभिव्यक्ति (constant expression) चल जाती है, इसलिए तुलना वाले लेबल लिखना अपने आप में ग़लत नहीं — उनका मान संकलन के समय ही 1 और शून्य निकल आता है। असली चूक यह है कि तीसरे लेबल से बना शून्य पहले वाले case 0 से टकरा जाता है, और एक ही switch में दो case की क़ीमत एक नहीं हो सकती। डुप्लिकेट case मिलते ही संकलक (compiler) रुक जाता है, सो उत्तर कम्पाइल टाइम एरर है।
A case label may use any constant expression, so labels written with a comparison are not wrong in themselves; their values are worked out at compile time as 1 and zero. The real fault is that the zero produced by the third label clashes with the earlier case 0, and two case labels in the same switch can never carry the same value. On finding a duplicate case the compiler stops, so the answer is a compile time error.
प्रश्न 4उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    int a = 65;

    switch(a)

    {

         case 'A':

                       printf("FliQi");

                       break;

              case 65:

                   printf("FliQi India");

                       break;

              default:

                   printf("FliQi Education");

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    int a = 65;

    switch(a)

    {

         case 'A':

                       printf("FliQi");

                       break;

              case 65:

                   printf("FliQi India");

                       break;

              default:

                   printf("FliQi Education");

    }

}
  1. AFliQi
  2. BFliQi India
  3. CFliQi Education
  4. DCompile Time Error

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

हल / Solution
ASCII में 'A' का मान 65 है। इसलिए case 'A' और case 65 दोनों एक ही मान 65 बताते हैं। एक switch में दो case का मान एक जैसा नहीं हो सकता। इसलिए compiler duplicate case value error देता है और प्रोग्राम चलता नहीं। अगर इनमें से एक case हटा दिया जाए, तो a = 65 होने पर बचा हुआ case चलता। यहाँ FliQi, FliQi India या FliQi Education कुछ नहीं छपता।
In ASCII, 'A' has the value 65. So case 'A' and case 65 both stand for the same value, 65. Two cases in one switch cannot have the same value. So the compiler gives a duplicate case value error, and the program does not run. If one of these cases were removed, the remaining one would run for a = 65. Here none of FliQi, FliQi India or FliQi Education is printed.
प्रश्न 5उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    char ch[] = "FliQi";

    switch(ch)

    {

         case "FliQi":

                       printf("FliQi");

              default:

                   printf("FliQi Education");

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    char ch[] = "FliQi";

    switch(ch)

    {

         case "FliQi":

                       printf("FliQi");

              default:

                   printf("FliQi Education");

    }

}
  1. AFliQi
  2. BFliQi Education
  3. CFliQiFliQi Education
  4. DCompile Time Error

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

हल / Solution
ch एक char array है, यानी एक string। switch सिर्फ़ integer मानों पर चलता है, और case label भी integer constant होना चाहिए। यहाँ switch(ch) और case "FliQi" दोनों string से जुड़े हैं, इसलिए compiler error देता है। प्रोग्राम compile ही नहीं होता, इसलिए FliQi या FliQi Education कुछ भी नहीं छपता। string की तुलना के लिए strcmp() के साथ if-else लगाना पड़ता है।
ch is a char array, which means a string. A switch works only on integer values, and a case label must also be an integer constant. Here both switch(ch) and case "FliQi" involve strings, so the compiler gives an error. The program never compiles, so neither FliQi nor FliQi Education is printed. To compare strings, you need strcmp() with if-else instead of a switch.
प्रश्न 6उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    switch(printf("FliQi"))

    {

              case 20:

                   printf("FliQi 1");

                       break;

              case 60:

                   printf("FliQi 2");

                       break;

              default:

                   printf("INDIA");

                       break;

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    switch(printf("FliQi"))

    {

              case 20:

                   printf("FliQi 1");

                       break;

              case 60:

                   printf("FliQi 2");

                       break;

              default:

                   printf("INDIA");

                       break;

    }

}
  1. AFliQi 1
  2. BINDIA
  3. CFliQi INDIA
  4. DCompile Time Error

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

हल / Solution
printf() जितने अक्षर छापता है, उतनी संख्या लौटाता है। FliQi में 5 अक्षर हैं। इसलिए switch(printf("FliQi")) पहले FliQi छापता है और फिर switch(5) बनता है। 5 न case 20 से मेल खाता है, न case 60 से। इसलिए default चलता है और INDIA छपता है। पूरा आउटपुट FliQiINDIA है, जिसे विकल्प में FliQi INDIA लिखा है। सिर्फ़ INDIA ग़लत है, क्योंकि FliQi पहले छप चुका है।
printf() returns the number of characters it prints. FliQi has 5 characters. So switch(printf("FliQi")) first prints FliQi and then becomes switch(5). 5 matches neither case 20 nor case 60. So default runs and INDIA is printed. The full output is FliQiINDIA, shown in the option as FliQi INDIA. INDIA alone is wrong, because FliQi has already been printed. There is no error.
प्रश्न 7उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    int a=10, b=20;

    switch(a+b+30)

    {

            case 20:

                       printf("FliQi");

                       break;

              case 60:

                   printf("BHARAT");

                       break;

              default:

                   printf("INDIA");

                       break;

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    int a=10, b=20;

    switch(a+b+30)

    {

            case 20:

                       printf("FliQi");

                       break;

              case 60:

                   printf("BHARAT");

                       break;

              default:

                   printf("INDIA");

                       break;

    }

}
  1. AFliQI
  2. BBHARAT
  3. CINDIA
  4. DCompile Time Error

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

हल / Solution
switch में expression चल सकता है, बशर्ते नतीजा integer हो। यहाँ a + b + 30 = 10 + 20 + 30 = 60 बनता है। इसलिए switch(60) चलता है। case 20 मेल नहीं खाता। case 60 मेल खाता है और BHARAT छपता है, फिर break से switch ख़त्म। default का INDIA नहीं छपता। expression वैध है, इसलिए compile error नहीं आता। FliQi तब छपता जब नतीजा 20 होता।
A switch can use an expression, as long as the result is an integer. Here a + b + 30 = 10 + 20 + 30 = 60. So the code runs switch(60). Case 20 does not match. Case 60 matches, BHARAT is printed, and the break ends the switch. The INDIA of default is not printed. The expression is valid, so there is no compile error. FliQi would appear only if the result were 20.
प्रश्न 8उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    switch('A')

    {

         case  'A':

                   printf("FliQi");

                       break;

              default:

                   printf("INDIA");

                       break;

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    switch('A')

    {

         case  'A':

                   printf("FliQi");

                       break;

              default:

                   printf("INDIA");

                       break;

    }

}
  1. AFliQi
  2. BINDIA
  3. CCompiler Error
  4. DPrint Nothing

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

हल / Solution
switch('A') में character 'A' दिया गया है, जो अंदर से integer 65 है। character से switch करना पूरी तरह वैध है। case 'A' मेल खाता है, इसलिए FliQi छपता है। उसके बाद break है, इसलिए control switch से बाहर आ जाता है और default का INDIA नहीं छपता। कोई error नहीं है, और कुछ न छपने की भी कोई वजह नहीं है। इसलिए आउटपुट FliQi है।
switch('A') is given the character 'A', which is the integer 65 inside. A switch on a character is fully valid. Case 'A' matches, so FliQi is printed. A break follows, so control leaves the switch and the INDIA of default is not printed. There is no error, and there is no reason for nothing to be printed. So the output is FliQi.
प्रश्न 9उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    switch("FliQi")

    {

              case "FliQi":

                   printf("FliQi");

             default:

                       printf("INDIA");

                       break;

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    switch("FliQi")

    {

              case "FliQi":

                   printf("FliQi");

             default:

                       printf("INDIA");

                       break;

    }

}
  1. AFliQi
  2. BFliQi INDIA
  3. CINDIA
  4. DCompile Time Error

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

हल / Solution
switch("FliQi") में एक string दी गई है, और case में भी string लिखी है। C में switch सिर्फ़ integer मानों पर चलता है, string पर नहीं। string असल में characters की array होती है, जिसका पता pointer के रूप में जाता है। इसलिए compiler error देता है। प्रोग्राम चलता नहीं, तो FliQi या INDIA नहीं छपता। string की तुलना के लिए strcmp() और if-else लगाते हैं।
switch("FliQi") is given a string, and the case label is also a string. In C, a switch works only on integer values, not on strings. A string is really an array of characters, passed as a pointer to its first character. So the compiler gives an error. The program does not run, so neither FliQi nor INDIA is printed. To compare strings, use strcmp() with if-else.
प्रश्न 10उत्तर + हल
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    switch(5.3)

    {

             case 5:

                       printf("FliQi");

              case 5.3:

                       printf("FliQi India");

                       break;

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    switch(5.3)

    {

             case 5:

                       printf("FliQi");

              case 5.3:

                       printf("FliQi India");

                       break;

    }

}
  1. AFliQi FliQi India
  2. BFliQi India
  3. CFliQi
  4. DCompile Time Error

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

हल / Solution
switch(5.3) में 5.3 एक double मान है। switch का expression integer प्रकार का ही होना चाहिए। साथ ही case 5.3 भी दशमलव है, जबकि case label integer constant होना चाहिए। इन दोनों वजहों से compiler error देता है। प्रोग्राम compile नहीं होता, इसलिए FliQi या FliQi India कुछ भी नहीं छपता। दशमलव मान पर फ़ैसला करना हो तो if-else लगाना पड़ता है।
In switch(5.3), the value 5.3 is a double. The switch expression must be of an integer type. Also, case 5.3 is a decimal value, while a case label must be an integer constant. For both reasons the compiler gives an error. The program does not compile, so neither FliQi nor FliQi India is printed. To decide on decimal values, you must use if-else instead.
आगे के 20 प्रश्नों के उत्तर और हल app मेंFliQi Question Bank — अभ्यास, हल और आपकी प्रगति
App खोलिए
प्रश्न 11उत्तर app में
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    switch(5)

    {

        printf("FliQI");

        if(1)

            printf("Hi");

        else

            printf("Hello");

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    switch(5)

    {

        printf("FliQI");

        if(1)

            printf("Hi");

        else

            printf("Hello");

    }

}
  1. AHi
  2. BHello
  3. CFliQi Hi
  4. DPrint Nothing
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 12उत्तर app में
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    switch()

    {

              case :

                       printf(“FliQi”);

            default :

                       printf("FliQi India");

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main(){

    switch()

    {

              case :

                       printf(“FliQi”);

            default :

                       printf("FliQi India");

    }

}
  1. AFliQi
  2. BFliQi India
  3. CFliQiFliQi India
  4. DCompile Time Error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 13उत्तर app में
स्विच केस के बारे में कौन सा कथन असत्य है?
Which statement is false about switch case?
  1. Aहमें स्विच के अंदर सबसे आखिर में डिफॉल्ट स्टेटमेंट लिखना होगा।We must write the default statement at the last inside the switch.
  2. Bएक स्विच में डिफॉल्ट स्टेटमेंट का उपयोग केवल एक बार किया जा सकता है।The default statement in a switch can be used only once.
  3. Cहम किसी भी स्टेटमेंट को केस या डिफॉल्ट के बाहर लिखते हैं लेकिन कोई कंपाइल टाइम एरर नहीं होगा।we write any statement outside case or default but no compile time error will occur.
  4. Dडिफ़ॉल्ट केस को एक्सीक्यूट किया जाएगा यदि और केवल अगर कोई केस मैच नहीं खाता है।Default case will be executed if and only if there is no case matched.
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 14उत्तर app में
स्विच केस के बारे में कौन सा कथन असत्य है?
Which statement is false about switch case?
  1. Aहम केस लेबल के रूप में केवल int और char कॉन्सटैंटऔर वेरिएबल ले सकते हैं।We can take only int and char constants and variables as case label.
  2. Bडुप्लीकेट केस लेबल की अनुमति नहीं है अन्यथा हमें कंपाइल टाइम एरर मिलेगा।Duplicate case labels are not allowed otherwise we will get compile time error.
  3. Cएक स्विच में डिफॉल्ट स्टेटमेंट का उपयोग केवल एक बार किया जा सकता है।The default statement in a switch can be used only once.
  4. Dडिफ़ॉल्ट केस को एक्सीक्यूट किया जाएगा यदि और केवल अगर कोई केस मैच नहीं खाता है।Default case will be executed if and only if there is no case matched.
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 15उत्तर app में
स्विच केस के बारे में कौन सा कथन असत्य है?
Which statement is false about switch case?
  1. Aस्विच आर्गुमेंट के लिए अलाउड आर्गुमेंट प्रकार char, Short, int, long int हैं।The allowed argument types for the switch arguments are char, short, int, long int.
  2. Bहम खाली स्विच लिख सकते हैं जिसमें कोई केस और डिफॉल्ट उपलब्ध नहीं है।We can write empty switch in which there is no case and default available.
  3. Cप्रत्येक केस लेबल कॉन्सटैंट या कॉन्सटैंट एक्सप्रेशन होना चाहिए।Every case label should be constant or constant expression.
  4. Dस्विच आर्गुमेंट एक एक्सप्रेशन नहीं हो सकता।switch arguments cannot be an expression.
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 16उत्तर app में
निम्नलिखित C प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

    int x;

    float y=7.0;

    switch(x=y+1)

    {

        case 8: printf("It's Eight.");

          break;

        default: printf("Oops No choice here!!!");

    }

}
What will be the output of following C Program?

#include <stdio.h>

int main()

{

    int x;

    float y=7.0;

    switch(x=y+1)

    {

        case 8: printf("It's Eight.");

          break;

        default: printf("Oops No choice here!!!");

    }

}
  1. AError
  2. BOops No choice here!!!
  3. CIt's Eight.Oops No choice here!!!
  4. DIt's Eight.
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 17उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

#define TRUE 1

int main()

{

    switch(TRUE)

    {  

        printf("Hello");

    }

}
What will be the output of the following program?

#include <stdio.h>

#define TRUE 1

int main()

{

    switch(TRUE)

    {  

        printf("Hello");

    }

}
  1. AHello
  2. BERROR
  3. CNo Output
  4. DGarbage Value
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 18उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

void main(){

    int a=1;

    switch(a/2)

    {

        case NULL:

            printf("Case NULL\n");

            break;

        case 0:

            printf("Case ZERO\n");

            break;

        default:

            printf("DEFAULT\n");

            break;

    }

}
What will be the output of following program ?

#include <stdio.h>

void main(){

    int a=1;

    switch(a/2)

    {

        case NULL:

            printf("Case NULL\n");

            break;

        case 0:

            printf("Case ZERO\n");

            break;

        default:

            printf("DEFAULT\n");

            break;

    }

}
  1. ACase NULL
  2. BCase ZERO
  3. CCase DEFAULT
  4. DError
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 19उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

void main()

{

    int a=2;

    switch(a/2*1.5)

    {

        case 1:

            printf("One...");

            break;

        case 2:

            printf("Two...");

            break;

        default:

            printf("Other...");

            break;

    }

}
What will be the output of following program ?

#include <stdio.h>

void main()

{

    int a=2;

    switch(a/2*1.5)

    {

        case 1:

            printf("One...");

            break;

        case 2:

            printf("Two...");

            break;

        default:

            printf("Other...");

            break;

    }

}
  1. AOne...
  2. BTwo...
  3. COther...
  4. DError
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 20उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

void main()

{

    short a=2;

    switch(a)

    {

        case 1L:

            printf("One\n");

            break;

        case 2L:

            printf("Two\n");

            break;

        default:

            printf("Else\n");

            break;

    }

}
What will be the output of following program ?

#include <stdio.h>

void main()

{

    short a=2;

    switch(a)

    {

        case 1L:

            printf("One\n");

            break;

        case 2L:

            printf("Two\n");

            break;

        default:

            printf("Else\n");

            break;

    }

}
  1. AOne
  2. BTwo
  3. CElse
  4. DError
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 21उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

void main()

{

    short day=2;

    switch(day)

    {

        case 2: || case 22:

            printf("%d nd",day);

        break;

        default:

            printf("%d th",day);

        break;  

    }

}
What will be the output of following program ?

#include <stdio.h>

void main()

{

    short day=2;

    switch(day)

    {

        case 2: || case 22:

            printf("%d nd",day);

        break;

        default:

            printf("%d th",day);

        break;  

    }

}
  1. A2 nd
  2. B22 nd
  3. CError
  4. D2 nd 22 nd
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 22उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

void main()

{

    int a=2;

    int b=a;

    switch(b)

    {

          printf("Message ");

        case a:

            printf("Case-2 ");    

              break;

        case 3:

            printf("Case-3 ");    

              break;

        default:

            printf("No option "); 

              break;

    }

    printf("Exit from switch");

}
What will be the output of following program ?

#include <stdio.h>

void main()

{

    int a=2;

    int b=a;

    switch(b)

    {

          printf("Message ");

        case a:

            printf("Case-2 ");    

              break;

        case 3:

            printf("Case-3 ");    

              break;

        default:

            printf("No option "); 

              break;

    }

    printf("Exit from switch");

}
  1. ACase-2
  2. BError: case expression not constant.
  3. CMessage Case-2
  4. DCase-2 Case-3 Exit from switch
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 23उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

void main()

{ 

    int a=2;

    switch(a)

    {

        printf("Message ");

        default:

            printf("Default ");

        case 2:

            printf("Case-2 ");

        case 3:

            printf("Case-3 ");

    }

    printf("Exit from switch ");

}
What will be the output of following program ?

#include <stdio.h>

void main()

{ 

    int a=2;

    switch(a)

    {

        printf("Message ");

        default:

            printf("Default ");

        case 2:

            printf("Case-2 ");

        case 3:

            printf("Case-3 ");

    }

    printf("Exit from switch ");

}
  1. ACase-2
  2. BMessage
  3. CMessage Case-2
  4. DCase-2 Case-3 Exit from switch
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 24उत्तर app में
निम्नलिखित प्रोग्राम का आउटपुट क्या होगा?

#include <stdio.h>

void main()

{ 

    int a=10;

    switch(a){

        case 5+5:

            printf("Hello ");

        default:

            printf("OK ");

    }

}
What will be the output of following program ?

#include <stdio.h>

void main()

{ 

    int a=10;

    switch(a){

        case 5+5:

            printf("Hello ");

        default:

            printf("OK ");

    }

}
  1. AHello
  2. BOK
  3. CHello OK
  4. DError
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 25उत्तर app में
निम्नलिखित सी कोड का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    int a = 1;

    switch (a){

       case a:

          printf("Case A ");

       default:

          printf("Default");

    }

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

#include <stdio.h>

int main(){

    int a = 1;

    switch (a){

       case a:

          printf("Case A ");

       default:

          printf("Default");

    }

}
  1. AOutput: Case A
  2. BOutput: Default
  3. COutput: Case A Default
  4. DCompile time error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 27उत्तर app में
निम्नलिखित सी कोड का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    int a = 1;

    switch (a)

      case 1:

        printf("%d", a);

      case 2:

        printf("%d", a);

      case 3:

        printf("%d", a);

      default:

        printf("%d", a);

}
Comment on the output of the following C code.

#include <stdio.h>

int main(){

    int a = 1;

    switch (a)

      case 1:

        printf("%d", a);

      case 2:

        printf("%d", a);

      case 3:

        printf("%d", a);

      default:

        printf("%d", a);

}
  1. ANo error, output is 1111
  2. BNo error, output is 1
  3. CNo error, output is 1234
  4. DCompile time error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 28उत्तर app में
निम्नलिखित सी कोड का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    switch (printf("Do")){

       case 1:

          printf("First\n");

              break;

       case 2:

          printf("Second\n");

          break;

       default:

          printf("Default\n");

          break;

    }

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

#include <stdio.h>

int main(){

    switch (printf("Do")){

       case 1:

          printf("First\n");

              break;

       case 2:

          printf("Second\n");

          break;

       default:

          printf("Default\n");

          break;

    }

}
  1. ASecond
  2. BDoFirst
  3. CDoSecond
  4. DDoDefault
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 29उत्तर app में
निम्नलिखित सी कोड का आउटपुट क्या होगा?

#include <stdio.h>

int main()

{

    float f = 1;

    switch (f){

       case 1.0:

          printf("yes\n");

          break;

       default:

          printf("default\n");

    }

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

#include <stdio.h>

int main()

{

    float f = 1;

    switch (f){

       case 1.0:

          printf("yes\n");

          break;

       default:

          printf("default\n");

    }

}
  1. Ayes
  2. Byes default
  3. CUndefined behaviour
  4. DCompile time error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
प्रश्न 30उत्तर app में
निम्नलिखित सी कोड का आउटपुट क्या होगा?

#include <stdio.h>

int main(){

    int x = 97;

    switch (x){

       case 'a':

          printf("yes ");

          break;

       case 97:

          printf("no\n");

          break;

    }

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

#include <stdio.h>

int main(){

    int x = 97;

    switch (x){

       case 'a':

          printf("yes ");

          break;

       case 97:

          printf("no\n");

          break;

    }

}
  1. Ayes
  2. Byes no
  3. CDuplicate case value error
  4. DCharacter case value error
उत्तर और हल FliQi Question Bank app में देखें (Answer & solution in the app)
Switch Case in C Language के सभी 49 प्रश्न — उत्तर, हल और अभ्यास

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

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

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

C Language के दूसरे topics

सभी topics