Sei sulla pagina 1di 1

/* Counting vowels and consonants in a given line of text */ #include<stdio.h> #include<string.

h> int main() { char str[80]; int i,vow=0,cons=0; printf("Enter a string : "); scanf("%[ ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqr stuvwxyz]",str); for (i = 0; i < strlen(str); i++) if (str[i] == 'A' || str[i] == 'E' || str[i] == 'I' || str[i] == 'O' || str[i] == 'U' || str[i] == 'a' || str[i] == 'e' || str[i] == 'i' || str[i] == 'o' || str[i] == 'u') vow++; else if (str[i] != ' ') // Ignore BLANK characters cons++; printf("\n\nThe given string is %s",str); printf("\n\nThe total number of VOWELS in a given string is %d",vow); printf("\nThe total number of CONSONANTS in a given string is %d",cons); return 0; } /* End of Main */

Potrebbero piacerti anche