 Hello friends, I am Sanjay Gupta. In this video, I am going to demonstrate you how you can use array in switch statement. So for demonstration purpose, I will be implementing these three logics. Some of array count even an odd elements available in array and some of positive and negative values which are available inside array. Before starting, you can note my information. You can watch and subscribe my YouTube channel through this link, youtube.com slash sanjaygupta underscore tax school. You can download my programming app TechMS which is available on Google Play. Now coming on to the topic, I will be implementing array inside switch statement so that you can understand how you can use array with switch. First of all, I am including a header file sdio.h the main function. Inside main, I am declaring an array I variable then counter one equals to zero counter two equals to zero. Then with the help of printf, I will be showing this message on console enter 10 elements to receive elements. I am implementing this for loop. This for loop will repeat 10 times and it will also repeat this scan of statements so that all the elements which which will be entered by the user will be stored inside this array a with the help of the index I. So scanner will receive 10 elements at different indexes and all those elements will be stored inside array a. After reading the elements, I have to show the choices which are available for the user. So I am using printf statement for that purpose. So I am showing first option that is sum of array. Then second printf it will display count even an odd elements from array. Third printf it will display sum of positive and negative values. Then again printf it will display enter your choice message on console to receive choice from user. I am using scanf person d comma m person ch. The ch variable will receive choice from user and I am declaring this variable as integer variable. So this way elements of array is received using foreign scanf. Then printf is printing all the options which are available for user and then last printf and scanf both are reading the choice which is entered by the user. Now I am applying switch. Inside switch I am passing ch as choice. Then I am implementing case one. In case one I have to perform addition operation that is sum of array. For that purpose I am implementing a for loop. Inside this for loop I am adding c1 equals to c1 plus a of i. So all the elements of array is being added with c1. After completion of this loop I have to print the result. So sum of array equals to person d comma c1. Now break. So this is the implementation of case one. After case one I am going to implement case two. In case two I have to count even and odd elements from array. Again I am implementing for loop. Inside this for loop I have to implement if else statement. I am checking a of i modulus to double equals to zero. If this condition is true then number is even otherwise it is odd. So I am counting c1 plus plus else c2 plus plus. So this way I have implemented for loop which is checking whether the number is even or odd. So if number is even then c1 will be incremented by one. Otherwise c2 will be incremented by one. After completion of this loop I have to print the results. So even quantity equals to person d slash an odd quantity equals to person d then c1 comma c2. So this way counted even and odd quantities will be displayed on console and then I am using break. Then case three. In case three I have to add positive and negative values. For that purpose I am implementing a for loop which will repeat 10 times. Inside this loop I am implementing if statement which will check whether the number is positive or negative. So if number is positive then it will be added with c1 else if number is negative then it will be added with c2. So this way c1 is containing addition of positive numbers and c2 is containing addition of negative numbers. After completion of loop I have to show both the sums. So positive sum equals to person d slash an negative sum equals to person d c1 comma c2. So this way positive and negative sum will be displayed on console then I am using break keyword to break case three. Then I am implementing default. If any case will not be executed then automatically default will be executed and this default will print message long toys entered by the user. So then I have come closed switch statement and then main. So this is the complete implementation of this program. So I have implemented array with help of switch statement so that a particular operation can be executed as per the user's choice. Now I am executing this code. You can see it is asking for 10 elements. So first time I am entering 10 times 1. Now it is showing the choices. First sum of array, second count even an odd elements from array and third one is sum of positive and negative values in array. So I am entering 1. You can see the output sum of array is 10. So this way you can see case one is executed properly. Now if you want to execute case number 2 that will count even an odd values. For that purpose I have entered 10 values. Now I am entering choice number 2. You can see even equals to 5 and odd equals to 5. So total 10 elements are available 5 are even and 5 are odd. So correct results are displayed again. So case 2 is working properly. Now I am again executing this code. This time I am entering both negative and positive values. I am entering choice number 3. You can see the result positive equals to 5 and negative is equals to minus 5. So 5 positive numbers are added and 5 negative numbers are added. So this way you can see all the choices are working properly. Now let's check whether default is working or not. So I am entering 10 numbers. If I enter 4 as choice it will display or it is right now displaying wrong choice because I have implemented default. So friends this way you can implement array with the help of switch statement so that you can implement multiple logics but only one logic will be executed as per the user's choice. So switch statement is suitable for that purpose. I hope you have understood how you can manage arrays with the help of switch statement with the help of this demonstration. If you want to watch more programming related videos you can follow or subscribe my YouTube channel. URL is youtube.com slash sanjaygupta underscore tech school which is available in front of you. You can also download my programming app TechMS that is available on Google Play. It contains various tutorials regarding programming languages. If you want to watch more programming related videos so keep following my YouTube channel download my app. Thank you for watching this video.