#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;
}