You must use a pointer to a C-string and dynamically allocate just enough memory
ID: 3675071 • Letter: Y
Question
You must use a pointer to a C-string and dynamically allocate just enough memory to store all the characters entered by the user PLUS the '0' char than must be appended at the end of the C-string. Asks the user to enter any string (any sequence of characters) The program should display all the vowels that are present (upper case or lower-case) The program should display the vowel which appears most frequently in the string (user input) AND the number of times it appeared. The user must be asked if he/she wants to continue entering values or quit. Comment your code Use meaningful or mnemonic variable names You may not use global variables You may not use GOTO statements You may not use variables of type string, but you may use literal strings You may not use infinite loops for(;;) while(true) you may not use the break statement to exit loopsExplanation / Answer
Find the number of vowels #include #include #include int main() { char *pointer; char vowels[] = {'a', 'e', 'i', 'o', 'u', 'A', 'E', 'I', 'O', 'U'}; int counta=0; int counte=0; int counti=0; int counto=0; int countu=0; int vowel = 0, cons = 0, digit = 0; int flag = 0, i pointer = (char *)malloc(sizeof (char) * 100); /* In order to get the input string from user */ printf("Enter the input string :"); fgets(pointer, 100, stdin); pointer[strlen(pointr) - 1] = ''; /* We will now parse the string to find the no of vowels here while (*pointer != '') { for (i = 0; i < 10; i++) if (*pointer == vowels[i]) { flag = 1; break; } if (flag) { /* Total number of vowels */ vowel++; flag = 0; } printf("No of vowels in the string are: %d ", vowel); if (*pointer ==a) {counta++;} if (*pointer == e) counte++; if (*pointer == i) counti++; if (*pointer == o) counto++; if (*pointer == u) countu++; coutRelated Questions
Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
drjack9650@gmail.com
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.