/****************************************************************************** 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); }
Preview:
downloadDownload PNG
downloadDownload JPEG
downloadDownload SVG
Tip: You can change the style, width & colours of the snippet with the inspect tool before clicking Download!
Click to optimize width for Twitter