#include %26lt;ctype.h%26gt;
void count(const char *str,
unsigned int *vowels,
unsigned int *constants) {
char *s = str;
*vowels = 0;
*constants = 0;
while (s) {
switch (tolower(*s)) {
case 'a':
case 'e':
case 'i':
case 'o':
case 'u':
(*vowels)++;
break;
default:
if (isalpha(*s))
(*constants)++;
}
s++;
}
}
Umm... Sorry, but can you explain what the most efficient way using library calls?
How to create a C program that will count the number of VOWELS and CONSONANTS in a inputted string?
2 ways to do this one is very basic and innefficient the other can be very complex but using existing library functions to do the work for ya
basic way is just a loop and compare one character at a time for any of the vowels
the other is to check out the string.h library
read the functions closely there is more than 1 way to do it
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment