Hello friends. I'm Sanjay Gupta. I welcome you on Sanjay Gupta Tech School. So in this video, I'm going to explain how you can count how many visits are odd and how many visits are even in a given number, right? So before starting, if you go to a detail or description of this video, you will find various links related to playlists. So you can watch them. Those playlists are related to various videos based on programming. So now I'm explaining how you can implement the logic for this. For example, we have a number 1 0 5 3 1 0 5 3. So we need to count how many visits are even and how many visits are odd in this number. So this number is containing four visits. So we need to take each visit individually from this number and then we will divide that visit by two. If that visit is completely divisible by two, then it is even, otherwise odd. So here you can see 1 is odd, 5 is odd and 3 is odd. So total odd visits are 3 and even visit, sorry, even visit is 1. Now, if we take another number, so let's say number is 2 4 3 6. Number is 2 4 3 6. So here 2 4 and 6, these are even and 3 is odd. So if we take this example, so here you can see odd number is 1 and even is 3. So after this explanation, now I'm going to implement a program. So you will learn how we can implement a C program for this requirement. So these are the variables that will be required and A, C1, C2. So C1, let's say, will be storing even count and C2 will be storing odd count. Or you can take even and odd as a name of the variable. So that depends upon your requirement, how you can use the variable names. Then a printf enter a number, then scanf or send d and percent n. So the input number will be stored inside the same variable. Now, we can apply a loop inside that loop. We need to apply if condition so that we can check whether that is even or odd. So I am implementing a loop. So here you can see its condition is n greater than 0. So first time implementing the logic and then I will explain that logic with the example that we took earlier. So let's say A equals to n modulus 10. So now I'm applying if A modulus 2 W equals to 0. So I am counting C1 plus plus else I'm counting C2 plus plus and then n equals to n by 10. So this is the loop that I'm going to use for solving this problem. So now I'm taking one example. So let's say our number is 2.36. C1 is 0. C2 is 0. Right. Now start from here. So why n is greater than 0? So it is true. Then n modulus 10. So whenever we divide a number by 10 and we want to receive its remainder. So remainder will be always last digit. So A will be having fits. Now we need to divide A by 2. So again we are taking remainder. So if A modulus 2 its remainder is equals to 0. So this time A is 6. So 6 is completely divisible by 2. So here remainder will be 0. So 0 is equals to 0. So C1 will be counted as 1. C1 will be counted as 1. So if condition is true, so we will not move to else part. And here you can see I have not used curly braces. So if it's having one statement, else is also having one statement. And this n equals to n by 10 is not related to C1. So after combination of if else, this will execute on this. So n is equals to n by 10. So value of n is 2.36. So now if I divide it by 10, so its result will be 2.43. Because after 2.43 there will be 0.6. So if we are taking variable as of integer type, so 0.6 will be removed. So finally outcome is 2.43. Now repeat same process again and again. So again number is 2.43 which is greater than 0. Find the modulus. So this time modulus will be 3. Again divide A modulus 2. So 3 modulus 2, remainder will be 1. So this condition is false now. So you need to increase C2. So this time C2 will be 1. Now after completion of if else condition, then we came here. So n divided by 10. So n is 2.43. So it will remain 24. Now again check the condition. It is true. n modulus 10. So here this time A will receive 4. So 4 is completely divisible by 2. So remainder will be 0. So we need to increase C1. Then n by 10. So n will be having 2. Check this condition. It is true. 2 modulus 10. So A will be having 2 this time. So 2 modulus 2 remainder will be 0. So again C1 will be incremented. So it is 3. C2 is not incremented because condition is 2. Then again divide 10 by 10. So this time n is 2. So 2 by 10. Zero point something. So this time n will be having 0. So here you can see now this loop will not repeat because n is 0 right now. And in C1 we have 3. In C2 we have 1. So C1 is related to even and C2 is related to odd. So here you can see both are having same value. So after completion of this loop we can print even equals to percent d odd equals to percent d. So for even we took C1 or odd we took C2. So C1 will print a value here. C2 will print value here. And even equals to the value of 3 odd equals to the value 1 will be printed and output. And then you can close the main function. So this way I explain to you how you can count how many digits are odd and how many digits are even in a given number. So inside why loop be used if else also. So I hope you understood whatever I explained in this video. If you want to watch more programming related videos you can open my channel go to playlist and there you will find more than 1000 videos related to computer. So do watch them follow my video and channel. Thank you for watching this video.