 Hello and welcome to this second video in this set of lectures. In these video lectures, we shall be looking at how to solve a particular problem by using for loops and if condition. The objective of this video series is to help students with problem solving and to prepare them for competitive programming. So at the end of this session, students will be able to solve a particular problem by writing a C program using loops and if condition. So these are the prerequisites as the earlier videos I highly recommend you to go through these particular videos before approaching to solve this particular problem that we are going to discuss in today's video lecture. So this is the problem statement. Under your given a string of random n characters, our approach to solve the problem is to write an efficient C code to find the number of vowels in the string and print the total number of all vowels that are present in the string. If you watch the previous video I had written or shared a code to find the number of vowels in a particular string. But in this particular problem, we are going to find out the number of the number of vowels as well as how many number of a particular vowel is present in the string. Say for example, I pass America as the input or the input string is America. Now if we carefully see this particular string of characters has four vowels. Now if you remember vowels in English alphabet are A, E, I, O, U. So we want to find out how many vowels are present and what is the number of the vowels which are present in the string. If you carefully see there are two A's starting and the ending character is A, there is a single E as well as a single I. So the total number is four but they are split as A is 2, E is 1 and I is 1. So we want to find out that in an entire given string how many vowels are present and what is the number of vowels that are present in the string. So first we shall discuss the algorithm that is required. So this is the algorithm. First we input or we take the input string from the user, store it in a variable say for example, I would like to call this variable of character array as str. Now our input string is stored in str. Now we initialize the array alpha, I take another character array name it as alpha to store the vowels and another array count to store the number of each vowel occurring in the string. Now we want the count of A's, the count of E, the count of I and the count of O and U in a given string. So we will store A, E, I, O, U in an array and we will take another array which will store the count of A, E, I, O, U. So we need two arrays. I will name one array as alpha and the other array as count to do this computation. Now as earlier we will scan the string from start till end and if vowel occurs that is any character from A, E, I, O, U occurs we will increment the respective vowel variable by one and we will do it till we reach the end of the string. And once it is done we will display the found vowels only and the count of the vowels. Now I shall switch my screen and we shall see how the problem is to be solved. Now I am using code blocks IDE, I highly recommend students to use code blocks IDE for it is a freely available software and you can keep all your codes together in one place in one project so that you can switch from one program to other program or project and do it quite comfortably. So as seen in the algorithm I am going to declare the string of max size where max size is 100 so I am potentially looking at a string of maximum size 100. As discussed in the algorithm I am storing all the vowels A, E, I, O, U in a character array alpha and also the count of the particular vowels I have initialized it to 0. Now you need not to worry since I have written it in small of course we will be scanning for both the small as well as the large capital letters and we are going to detect all of the vowels. This is just for storing and calculation okay so I have taken two arrays and I have stored the count of them at the starting of the program as 0. Now this is the step one we take the input of the string you can use F get S function which will take a maximum input of 100 characters or you can also use scan F function as I have written it here on line number 18 or else you can also use get S function but using F get S function is recommended and it will store all the input that we take from the keyboard into str array which we have declared here the character array. Now we come to step number two, now step number two we declare vowel as we initialize vowel as 0 and we want to scan the entire string. Now the limit of the string is the length of the string so using this str l en function we store the length of the string in the variable l en. Now moving ahead we want to detect the vowels in the string now we are using is alpha function here on line number 39 now what is alpha function does is it scans every character we are using it to scan every character in our input string and it is a function to check if the past character to is alpha function is an alphabet or not. What this function does is if it is an alphabet it returns a non-zero value. So if this function here returns a non-zero value stating that it is a character in the English alphabet that is any of the characters from the English alphabet this complete if condition will be activated if there is a say for example if there is a space or if there is a comma or an exclamation in the or a full stop in the string that will be avoided that will not be considered. So if it is an English character or an alphabet what happens is this block this if condition is activated and the control comes here and we check that if the character is a small A or it is a capital A we increment the count of the 0th position that is the position that we have that we are using for A if it is a E we increment count one of one that is the second position as we know that there are only five vowels we have reserved the index position of the count one array from 0 to 4. So 0 will be used for A 1 will be used for E 2 will be used for I 3 will be used for O and 4 will be used for U. So when any of these characters are scanned and detected the respective count will be incremented and once the count is incremented what we will do is we will scan from 0 to 5 that is from A to U and if the count is not equals 0 that means if A is detected in the string then only the particular alphabet A and its count will be displayed or will be printed. If say for example O or U was not detected in the string the count respective count will remain 0 and it will not be printed. So this is the program that I have written I have shared the link the downloadable link in the description area you can see for this program I am going to check for its execution. So I enter a string as America and hit enter so as you can see there are two A's so the count of A which is detected is 2 the count of E again is detected and this one and the count of I is detected which is 1. Now O and U are not present in the string so the count remains 0 and since the count is 0 we have not printed it here so you can write the program and check the output for yourself. Now moving ahead I want you to pause the video here write the program for yourself now using the while loop you already have seen the program how we can detect the vowels and the number of vowels using for loop write down the same program using while loop. So we come back again and check how we can write the same program using a while loop so I will directly go to this step algorithm step 3 and instead of for loop we are writing a while loop now we want to scan the entire string from starting to ending so we will scan till the character is a new line character that is slash n so while string of I is not equal to the new line character that is enter so while enter is not pressed before doing this we have initialized variable I to 0 which we are going to use to scan the entire array if is alpha of string of I not equal to 0 that is as it is and after one particular character is scanned what we have to do is we have to increment I by 1 so that the for the next while loop the new character is detected. So this I incrementation is done in the while loop whereas the comparison of string and the if condition is till starting from line number 41 to 50 and at 51 line that is outside the if condition the block after the if condition we are incrementing I so if you use this while loop we can write the same program using file while loop and we can get the output it will also generate the same output so these are the references that I have used for the video lecture you can also refer to these references and it will benefit you a lot thank you.