Category
š
LearningTranscript
00:00Hello everyone. Today I'm going to cover another program of Switchcase. The program is that
00:09if I press 1, so it should display 1. If I press 2, so it should display 2. If I press
00:153 from the keyboard, so it should display 3. If I display any one of the number from
00:22the keyboard, so it should display what wrong number. It's very easy program. Let us see
00:29how to create it.
00:51Let us save it.
00:59I will take a variable x here, use a printf statement, enter a number and I will use what
01:17is scanf %d,%x. Now we will apply the Switchcase. If the value of x is 1, so what it should
01:37display? 1. Then what break? If the case is 2, then what it should display? 2. Then what
01:55break? If the case is 3, then what it should display? 3. Then what break? If any other
02:11number, if you have input from the keyboard, so what it should display? Wrong number. I
02:24hope everything is fine here. Let us run and see is it giving the correct result or
02:30not. I will click on the build. It's showing with UIN0 warning. I will run the program,
02:39input the value 3, so what it should display? 3. If I run one more time by inputting 2,
02:50it's displaying 2. When I input here what inside x what 2, so switch 2. It will come to the case
03:01label 2. This case 2 and it will display 2 and by break statement the program will end. Suppose
03:15if I input any other number, suppose 8, it should display what? Wrong number.