Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

#include using namespace std;//Write a function to return a string composed of t

ID: 3578439 • Letter: #

Question

#include using namespace std;//Write a function to return a string composed of the most//frequent lowercase letter found in each row of a 10 times 10//array of lowercase alphabetic chars in the range a through z.////If there is more than one most frequent character, use the//one that come first alphabetically.//Also, for no apparent reason associated with this problem, //review the definition of a latin square.//use neither cin nor cout//TODO: write all your below this line string mostFrequent (char c[10] [10]) {}//TODO: write all your above this line int main(){char c[10][10] = {'a', 'b', 'f', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'c', 'r', 'r', 'g', 'h', 'r', 'j', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'o', 'o', 'z', 'w', 'p', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'o', 'd', 'o', 'b', 'o', 'd', 'o', 'd', 'a', 'l', 'l', 'd', 'o', 'b', 'o', 'd', 'o', 'd', 'a', 'l', 'l', 'd', 'e', 'f', 'f', 'h', 'l', 'j', 'a', 'b', 'c', 'd', 'i', 'f', 'g', 'h', 'i', 'j', 'a', 'b', 'z', 'v', 'z', 'v', 'g', 'g', 'v', 'z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'e', 'a', 'b', 's', 'd', 'e', 'f', 'g', 'h', 's', 'j', }; cout

Explanation / Answer

Please use below code.Please from now onwards don't include the image for code.It's difficult for me to enter 10x10 array.

There is more chance of human errror.

#include<iostream>
#include<string>

using namespace std;

int return_max_char(char ch[10],int count_arr[26])
{
for(int i = 0; i < 10; i++)
{
count_arr[ch[i] - 'a']++; //increment character count by incrementing corresponding location value of array
}
int max_ele = count_arr[0];
for(int i = 1; i < 26; i++) //finding max frequency character
{
if(count_arr[i] > max_ele)
{
return i; //returning location of max frequency character
}
}
return 0;
}

string mostFrequent(char c[10][10])
{
char ret_str[11]; //array for storing max frequency char from each row

int count_arr[26]; //array for counting characters from rows of given array

for(int i = 0; i < 10; i++)
{
char ch_arr[10];
for(int j = 0; j < 10; j++)
{
ch_arr[j] = c[i][j]; //copying row into ch_arr
}
for(int k=0; k < 26; k++) //initialize array to 0 each time
count_arr[k] = 0;

int max_char = return_max_char(ch_arr,count_arr); //returning max frequency occurred character location
ret_str[i] = max_char + 'a'; //converting location into character and storing in char array
}
ret_str[10] = ''; //terminate string with
string str(ret_str); //copying char array into string class of C++

return str;


}
int main()
{
char c[10][10] = {
'a','b','f','d','e','f','g','h','i','j',
'a','b','c','r','c','r','g','h','r','j',
'a','b','c','d','e','f','g','h','o','o',
'z','w','p','d','e','f','g','h','i','j',
'o','d','o','d','o','b','o','d','o','d',
'a','l','l','d','e','f','f','h','l','j',
'a','b','c','d','i','f','g','h','i','j',
'a','b','z','v','z','v','g','g','v','z',
'a','b','c','d','e','f','g','h','i','e',
'a','b','s','d','e','f','g','h','s','j',
};

cout<<mostFrequent(c)<<endl;
return 0;
}

Please refer below output of code.

fcodbfiges

Process returned 0 (0x0) execution time : 0.030 s
Press any key to continue.