Rich (BB code):
#include <stdio.h>
#include<ctype.h>
void main(void)
{
char text[512], *ptr;
int keystrokes=0, vowels=0, alphabetic=0;
printf("Enter text: ");
gets(text);
for (ptr=text; *ptr; ptr++) {
if (*ptr <='127' ||*ptr >= '0') keystrokes++;
if (*ptr == 'a' || *ptr == 'e' || *ptr == 'i' || *ptr == 'o' || *ptr == 'u' ||*ptr == 'A' || *ptr == 'E' || *ptr == 'I' || *ptr == 'O' || *ptr == 'U')
vowels ++;
if ((*ptr >= 'a' && *ptr <= 'z') || (*ptr >= 'A' && *ptr <= 'Z')) alphabetic++;
}
printf("There were:\r\n");
printf(" %d vowel%s\r\n", vowels, vowels == 1 ? "" : "s");
printf(" %d alphabetic%s\r\n", alphabetic, alphabetic == 1 ? "" : "s");
printf(" %d keystroke%s\r\n", keystrokes, keystrokes == 1 ? "" : "s");
return 0;
}
Last edited: