Count the vowels and consonants using Getchar/Putchar
Wed May 08 2024 04:12:48 GMT+0000 (Coordinated Universal Time)
Saved by
@Saging
#include <stdio.h>
#include <ctype.h>
int counta, counte, counti, counto, countu, countvowel, countconsonant;
int main()
{
char c;
printf("Input A string of characters: ");
while ((c=getchar()) != '\n')
if (c == 'a' || c == 'A' || c == 'e' || c == 'E' || c == 'i' || c == 'I' || c == 'o' || c == 'O' || c == 'u' || c == 'U') {
countvowel++;
} else
countconsonant++;
printf("vowels = %d \n", countvowel);
printf("consonants = %d \n", countconsonant);
return (0);
}
content_copyCOPY
Comments