Count the Vowels
Wed May 08 2024 04:11:46 GMT+0000 (Coordinated Universal Time)
Saved by
@Saging
/******************************************************************************
create a program that will accept a stream of characters
and will display the count of the vowels and consonant
*******************************************************************************/
#include <stdio.h>
#include <ctype.h>
int counta, counte, counti, counto, countu;
int main()
{
char c;
printf("Input A string of characters: ");
while ((c=getchar()) != '\n')
if (c == 'a' || c == 'A') {
counta++;
} else
if (c == 'e' || c == 'E') {
counte++;
} else
if (c == 'i' || c == 'I') {
counti++;
} else
if (c == 'o' || c == 'O') {
counto++;
} else
if (c == 'u' || c == 'U') {
countu++;
}
printf("a = %d \n", counta);
printf("e = %d \n", counte);
printf("i = %d \n", counti);
printf("o = %d \n", counto);
printf("u = %d \n", countu);
}
content_copyCOPY
Comments