In the given problem statement we have to accept the string and count the number of vowels in that string. There are two ways to accept the string namely 1) using white out space 2) using white space. In this problem we have to accept the string using white space. While accepting the string using white space we have to use a special format specifier %[^character] instead of %s. (As we know we use %s format specifier while accepting the string from user). So in the program below we use %[^\n] specifier. It means program accept every thing until new line character(\n)i.e. enter key is not encountered. So using this format specifier we accept required string with white space.
After accepting the string we calculate the length of the string using standard function strlen(). Then we execute a for loop which runs from zeroth location to length-1 location. For every iteration we check whether character at current location is equal to a,e,i,o,u,A,E,I,O,U and if match is fount we increment the counter by one otherwise go for next iteration. In this way we found the total count of vowels in the given string.
Please include stdio.h, conio.h and string.h header files before main function.
printf("Enter any string\n");
printf("\nEnterd string is %s",name);
printf("\nTotal number of vowels in the given string are %d",count);