# Can you help me please?

Enter text. Determine the percentage of use of each of the vowel letters in it (take into account lower and upper case letters). Record the result in descending order.

#### Kuncode

Enter text. Determine the percentage of use of each of the vowel letters in it (take into account lower and upper case letters). Record the result in descending order.
Here's a code snippet in C that takes a string as input and outputs the percentage of use of each vowel letter in the string:

C:
``````#include <stdio.h>
#include <string.h>
#include <ctype.h>

#define MAX_LENGTH 1000

int count_vowels(const char *str) {
int count = 0;
for (int i = 0; i < strlen(str); i++) {
char c = tolower(str[i]);
if (c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u') {
count++;
}
}
return count;
}

int main() {
char str[MAX_LENGTH];
int vowels[5] = {0};
char vowels_order[5] = {'a', 'e', 'i', 'o', 'u'};
printf("Enter a string: ");
fgets(str, MAX_LENGTH, stdin);

int total_vowels = count_vowels(str);
for (int i = 0; i < 5; i++) {
for (int j = 0; j < strlen(str); j++) {
char c = tolower(str[j]);
if (c == vowels_order[i]) {
vowels[i]++;
}
}
}

printf("Vowel usage in descending order: \n");
for (int i = 4; i >= 0; i--) {
float percentage = (float)vowels[i] / total_vowels * 100;
printf("%c: %.2f%%\n", vowels_order[i], percentage);
}
return 0;
}``````

This program uses the tolower function from the ctype.h library to convert the input string and the vowels to lower case letters, so that both upper and lower case vowels can be counted. Is this what you looking for ?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

### Members online

No members online now.