 इंज़ान बुब्ता आप देक्खष्कूँ, बहारद वियो सीरीज ल्गियो भीडियो सीरीज इंज़ान दिसकूँ, जानबादी मैं। तो लग्चर नहींत के दिसकूँँँँँँँँँँँँँँ, बहुततनो मैं, सेँटстаingta ke thoo mein. अगर आप को रीए यो साले दिकते हैं। सविज्च या किसे काम करता है। सविच आप सविच या चान करता है। स्विच बेसिक्छ या का79ईगन तो अप भ менक सेक्हने साले कि आँ रोने चड़े ती कि लरगा। सहीच सिच सेक्छन ठाख़़ँम कोगर लेईवन, you select one option from many cases, then switch statement is used to implement manual-driven programming for example, you must have visited an ATM machine, so when you enter a PIN number in an ATM machine, then you will see that there are many options available, so what you do is, you select one option and it performs its operation so we can do the same programming through switch so now the touchscreen is not available, we will get input from the user, for example, if you have called on customer care, then what does customer care tell you? that these choices are available, so if you want to speak in Hindi, then press one, if you want to speak in English, then press two, so that kind of programming is basically we will implement through switch, so as soon as this theoretical part is completed, then in practical implementation, you will see that I will tell you this whole implementation then switch is better than conditional statements, if we have many choices, so if you have a lot of choices available, then you have to select one option, so you can choose switch on place of choosing FLs, and some real life examples, like I told you about customer care, ATM machine, you can also control the menu of the host and restaurant through switch, we also give options for mobile phone menus, there are many options, and you select one, so all those are manual driven programming, so where touchscreen is available, we use touchscreen, where keyboard entry is available, we can use that, now after this theoretical explanation, now let's talk about syntax, so the rule of implementing switch and its format is available in front of you, so switch is basically a keyword, so I have already told you in the last video, that keyword is reserved words, we have to use them as it is, then you can see the parenthesis of switch, we have to use an integer expression, now what happens is, we will write this integer expression here, that integer expression, constant 1, constant 2, constant 3, constant 4 and so on, we will try to match it, so if the integer expression matches with constant, that particular case automatically executes it, so switch is a keyword, case is another keyword, then suppose integer expression, case matches with constant 1, so this statement will be executed, and after that we have written break, so break is also a very important role, that if you don't write break, and let's say your constant 1 matches, means case 1 is running, so after executing the statement, it will run to case 2 itself, so if you want one case to match, then you have to use the break keyword after every case, so break is also a keyword, if case constant 2 matches, then it will run to 2 and all the other cases, so in that case, case 1 won't execute, because 2 matches and all the other cases will run, but if you haven't used break, and if any case doesn't match, then it will finally run to default, so default is also a keyword, so when will you run the statements in default, when any case doesn't match with the constant value, so theoretically what I have told you is listed in front of you, there are 4 key words of switch, case, default and break, so I have already told you in the circles that there are 4 key words, then always use integer and character constant with case keyword, so here the constant 1, constant 2 you will use, or the integer expression used above, you can use integer or character, you can use character as it is internally converted to ask value, so ask value is what I have explained in the last video, when we had a program in fls, before that I had told you about ask value, so again if you are following the whole series, then you will know one by one, but if you are watching a video directly, then you better follow the whole series, if you are a beginner, if you are not a beginner, then you will know ask value, then you will understand, so whenever switch will not work on float, then you always have to use integer or character, then break is used to terminate execution of switch, so I have already told you this, if break is used and case matches, then it will work, break is not used, so whatever case matches, and after that all the cases will work, until the next break keyword is not there, and default is executed when integer expression does not match with any case constant, so when will the default work, when any case will not match, and break and default, both are optional in switch statement, so either one of them who has to use it or not, it depends on your choice, so I hope that you have understood this, now you are waiting for a practical example to be implemented, so the example I will implement, it will be a simple calculator, and it will perform one operation from these 5, that too on the user's choice, so we will display 1, 2, 3, 4, 5 options, the options selected by the user, according to the task performance, implement switch, we will implement switch, and I am including header file, stvio.h, after that main, now we declare the main function on variable, so now we have to perform addition, multiplication, subtraction, so you will have to perform 2 values, so let's say number 1, number 2, then the result will come, so res variable is made, and one variable is made, ch, so there will be choice, in which operation we have to perform, so first printf, in which we will display enter 2 numbers, then scanf, person d, person d, so we have to write this twice, so here person d, person d, write twice, and first value will go to n1, and second value will go to n2, so in this way 2 numbers are available, on which we have to perform calculation, now we will have to show the user, that menu, which operations are available to you, so as you use ATM machine, you can see the options, only then you can use, if you talk about customer care, then it gives you option, for which option you have to press, only then you press the number, similarly now we will display the menu, so now we will use printf, so you can say, please select any one option, now you will write printf, so we have written 1 for addition, then again printf, in this we have written 2 for subtraction, so if you want, then you can write only one printf, by using backslash, or you can use different printf also, so 3 for multiplication, then 4 for division, and 5 for modulus, so these 5 choices we have displayed, now after displaying the choices, we will have to read the choice also, so one more printf, and in this we have written, enter your choice, and the choice we will read, will be stored in which variable, ch variable, so in ch variable, 1 will come, 2 will come, 3 will come, 4 will come, 5 will come, or any other number can come, so you can mention here also, enter your choice, between 1 to 5, now everything is input, now we will start switch, so you will write switch, ch, so now this is our integer expression, meaning the value in ch, on the base of it, we will implement cases, and try to match, so I have written case 1, so this is constant value, so this 1 will try to match with ch, so if this matches, then we have to perform calculation, so I have written like this, result equals to n1 plus n2, so n1 and n2 are added to result, then we have written printf, sum equals to %d or is, and then we have written break, so now I am using break, later once we will run the program, I will remove the break, and tell you, from which you will get an idea, now we will copy this case, and paste it again and again, so I have pasted this 5 times, so this was case 1, now we will make it case 2, result will be minus, here we have written backslash, n or subtraction, then case 3, case 3 we will do multiplication, so here we have written for sum, multiplication, then case 4 will be division, and case 5 for modulus, okay, now after that you will write default, and print in default, you have entered wrong choice, so if anyone will enter anything other than 1,2,3,4,5, then this will be printed, so this way the program is completely implemented, now we will compile and run it, sorry I have run it directly, so first we will compile it, then we will choose this option, so it is compiled, there was no error in compilation, so it is running, so enter 2 number option, so I have entered 10, and I have entered 20, so I have entered 1, so sum equals to 30, then show, again we will run it, now I have entered 20,10, and I have entered 3, so multiplication equals to 200, so our program is running properly, this time I have entered 10,20, and I have entered choice as 7, so you see, it is running default, and it has shown that you have entered wrong choice, now let's talk about break, let's see what happens, so I am removing the break from case 1, and if I match the case 1, then case 1 will run, case 2 will run, but if there is a break on case 2, then it will stop the exhibition, if you have not put any break, then case 1,2,3,4,5, everything will run, so for demonstration, I have removed the break from case 1, so you will see, addition and subtraction will be on two values, so I have put the first value 20, and the second value 10, so there was some calculator, and subtraction calculator, because after subtraction there is a break, so the case 3,4,5, will not run, so you can use the break like this, so this is optional, if you use it, then it will work, if you don't use it, then it won't work, so if you don't write the choices, 1,2,3,4, if you write here 11, 12, 13, 14, 15, then it will work, so you have to write 11, 12, 13, 14 like this, so this is also valid, so this means you can put anything in constant value, it is not necessary, 1,2,3,4,5, you can enter it, so if you have put two values, chose 11, then see, some more subtraction will get printed, उसो मुस्ट्रक्छन दोनोग हैं कि आपी ब्रेग अंगे हदाएं तो फिर भी एकी कि यह सकुत रन करें। जिके आभ आप शुच रहें हो गो की क्यरक्तर कोंस्ट्रें को कैसे यूस करें तो क्यरक्तर कोंस्ट्रेंट के लि आपन इसको प्मवड़ फापे जो. तो अब यह जो सी एच है उसको अपर मनाते केरेक्टा ताएप का. तो मैंने सामिकोल न लगा और यह डाल दिया कैर सी एच. और यह जो अप्षन है, इनके पलेस पर अब अपन चेंच करेंगे. तो यह सको अटारेत है. यह सारे प्रिंटेस मैं यह से रिमूप कीए. तो अब यह आपको यह जो अप्षन है, इसके ज़ेगा मैं लिखना हो, प्लीज अंटर अनी अर्ठमाटिक अपरेटर. तो अर्ठमाटिक अपरेटर पाच होते है, तो उनको भी ब्रेकेट में डाल दिन है, प्लीजाश, माइनुस, मूल्टीपलाए, तवाए, मोडूलूस. चिए लेए इंपाच में से को यह यह एक अन्टर करना है, और वो रीडो जाएगा C-H वीगेगल मैं. तो अभी यह जो ते इनपूत यह करक्टर टाएग होगा. இ learnt as it is used but it will be modified so we'll use plus plus will be matched with plus, minus will match with minus so this way we can use character constant as it will be used internally in Ascii value So how does Ascii value work To understand it you can see a video in the playlist वो देख सकते हैं उस में आपको आस्काई लेएूस के बारे में पता चल जाएगा। बसी दियां देखना करेक्तर कोंस्टेंट हमेशा सिंबल कोट्स में आतें तो वो पोलो करना है देखन देखन देखन लेख सकते हैं you have entered wrong operator तो अब बना जो इनफोट डो इनफोट, तो यन्टीजर ताईप योंगे। and one more is character type और रव यजो सविच है वो वो करेक्तर कोंस्टेंट के बसिस पे खांपुश रें। this switch will work on the basis of character constant वो सेप किया, कमपाले न रण करते हैं। उस यहरर नहीं हैं तो 10, 20 थो ये चीस तो समज में आग़ग उगी विगी प्लस मैंग़ वाग लेए कैसे ज़ाम कर लैत अग़ अग़ ये क्यो लिखा पुकि हम जब तो ज़ नमभर इंपृ करते हैं तो नमभर मैंध इंपृ कियो थे टैंच फिर अंपर्ठ्प्र्स कियों after 20 inputs and then enter press so basically enter is also a character so when we are trying to read a character then enter is considered as a character so what we have to do is store that enter in any other character variable so that we can read this character so whenever you are programming in C then this problem can be faced a lot of times when you read the character after the integer so to do it, to bypass it you have to see a temporary character variable by declaring a function you have to use that so it will enter key and skip this particular part so that you can read it from other characters so in this way we have used the switch as well as the integer constant as well as the character constant and we have selected one of the options so I hope that you understand how to use the switch and the implementation of the program so thank you for watching this