In: Computer Science
Design an algorithm ( pseudocode or C ) to calculate the frequency of each of the vowels (lowercase and uppercase) in a text. The program will ask the user for a text, which will be entered by keyboard and will save, in a table (in%), the frequency of each of the vowels within the text, taking into account all the characters of the text. The text will end with the character '' # ''. Includes the emty sequence.
//Required program in c
#include<stdio.h>
void main()
{
char arr[1000][1000];
int i,j,l,c[10];
for(i=0;;i++)
{
for(l=0;l<10;l++)c[l]=0;
for(j=0;;j++)
{
scanf("%c",&arr[i][j])
;
if(arr[i][j]!='#'&&arr[i][j]!='\n'&&arr[i][j]!='\0'){
if(arr[i][j]=='a')c[0]++;
if(arr[i][j]=='A')c[1]++;
if(arr[i][j]=='e')c[2]++;
if(arr[i][j]=='E')c[3]++;
if(arr[i][j]=='i')c[4]++;
if(arr[i][j]=='I')c[5]++;
if(arr[i][j]=='o')c[6]++;
if(arr[i][j]=='O')c[7]++;
if(arr[i][j]=='u')c[8]++;
if(arr[i][j]=='U')c[9]++;
}
else{
printf("a
= %d, ",c[0]);
printf("A
= %d, ",c[1]);
printf("e
= %d, ",c[2]);
printf("E
= %d, ",c[3]);
printf("i
= %d, ",c[4]);
printf("I
= %d, ",c[5]);
printf("o
= %d, ",c[6]);
printf("O
= %d, ",c[7]);
printf("u
= %d, ",c[8]);
printf("U
= %d\n",c[9]);
break;
}
}
if(arr[i][j]=='\n'||arr[i][j]=='\0')break;
}
}