[23491 views]
In English language some of the alphabets a, e, i, o and u are known as the vowels.
The rest all the alphabets of English language which are not vowels are known as Consonants
So in this program we will be counting Vowels, Consonants, Space, any special character or digits.
So what we can think is we have to count characters so it should definitely run though a loop therefore we will run loop through each characters and check whether it vowel, consonants, digits or any other thing. For that we have to use If and else loop we will check if that character is vowel or digits.
Here in this algorithm we declare an array of characters which will be used to store the string. We declare digits, consonants, vowels and special for counting them and i for iterating the for loop. We use a for loop to iterate each character in the string. For Eg. Let's take "aebc 567 $%&" , this is our String. So in the for loop once a will go then e will go likewise the loop will run. When the a will go it will check if it is between a and z if Yes then it will check whether it is a, e, i, o, u. If yes, then vowels will become 1 and if it is not then consonants will become 1. If digits the it will go in the if statement condition of between 0 and 9 and for else any other character even the space will be counted as special character.
Note:Here, we have used gets and puts to enter the string and not scanf("%s") because gets store even the space while the scanf will store the Characters till the space character and not after that.