- [Prompt the user to enter a sentence, then hit newline. Read the sentence one character at a time,
- until you come to the newline character. Count the total number of keystrokes entered, the number of
- alphabetic characters, and the number of vowels ('a', 'e', 'i', 'o', and 'u'). Output these three
- counts]
End Result should look like this :
Keystrokes: 9999
Alpha Characters: 9999
Vowels: 9999
Only problem is when I insert a sentence... the CMD prompt does not continue... Any Help appreciated Please
Code:#include <stdio.h>
#include <stdlib.h>
#include <ctype.h>
int main(int argc, char *argv[])
{
int loop = 0; //Variable used for counting in the loop.
int keystrokes = 0; //Counts number of keystrokes.
int letters = 0; //Counts number of total letters.
int vowels = 0;//Counts number of vowels.
char sentence[9999]; //Defines the character array that will hold the input sentence. and fills it with the user's input.
printf("Sentence Analyzer.\n");
printf("Input your sentence(s), then hit enter.\n");
scanf(" %c", &sentence);
for(loop = 0; sentence[loop] != '\n'; loop++)
{
if (sentence[loop] = 'a'||'e'||'i'||'u')
{
++keystrokes;
++letters;
++vowels;
}
else
{
if (isalpha(sentence[loop]) == 1)
{
++keystrokes;
++letters;
}
else
{
++keystrokes;
}
}
}
printf("keystrokes%c\n ", keystrokes);
printf("Alpha Characters %c\n", letters);
printf("Vowels %c", vowels);
return 0;
}