if i have a an array with an amount of letters how can i writeand algorithm that
ID: 3609088 • Letter: I
Question
if i have a an array with an amount of letters how can i writeand algorithm that will give me the most common letter thatoccured for example s[ ] abacad //so 'a' is the letter that occured mostoften which is ACII 97 and # 0 of the alphabet(0-25) it's peanut butter //'t' is the most common ACII 116 andletter # 19 in alphabet thank you if i have a an array with an amount of letters how can i writeand algorithm that will give me the most common letter thatoccured for example s[ ] abacad //so 'a' is the letter that occured mostoften which is ACII 97 and # 0 of the alphabet(0-25) it's peanut butter //'t' is the most common ACII 116 andletter # 19 in alphabet thank youExplanation / Answer
please rate - thanks #include #include #include int main() {int letters[26]={0},i=0,max=0,index; char input[40],a; printf("Enter a sentence: "); gets(input); // for(int i=0; sentence[i]!=0; i++) while(input[i]!=0) { letters[tolower(input[i++])-97]++; } for(i=0;imax) {max=letters[i]; index=i; } printf("The letter that occurs most often is %c which is inposition %d",index+97,max); getch(); }Related Questions
Navigate
Integrity-first tutoring: explanations and feedback only — we do not complete graded work. Learn more.