Homework Solution: 1. Write a C++ program to perform the following tasks. Define an array of characters of size 15. Read 1…

    1. Write a C++ program to perform the following tasks. Define an array of characters of size 15. Read 15 characters from the user into the array. Next, read a search character from the user. The program should search for this character in the array. If found, report so, and also report the number times the search character occurs in the input array. Finally, the program should report what other character(s) in the input array occur(s) the same number of times as the search character. Suppose that your 15 character input is “aaaabbbbccccdef”, and the search character is ‘a’. Your program would state that ‘a’ is present in the input and that it occurs 4 times. It would also output stating that “The characters ‘b’ and ‘c’ occur the same number of times as that of ‘a’”.

    Expert Answer

     
    PROGRAM CODE: #include <iostream> using namespace std;

    1. Write a C++ program to discharge the cethcoming tasks. Define an draw-up of sorts of magnitude 15. Discover 15 sorts from the user into the draw-up. Next, discover a quest sort from the user. The program should quest ce this sort in the draw-up. If institute, description so, and besides description the compute times the quest sort happens in the input draw-up. Finally, the program should description what other sort(s) in the input draw-up happen(s) the selfselfselfselfsimilar compute of times as the quest sort. Suppose that your 15 sort input is “aaaabbbbccccdef”, and the quest sort is ‘a’. Your program would declare that ‘a’ is give in the input and that it happens 4 times. It would besides output stating that “The sorts ‘b’ and ‘c’ happen the selfselfselfselfsimilar compute of times as that of ‘a’”.

    Expert Defense

     

    PROGRAM CODE:

    #include <iostream>

    using namespace std;

    int ocean() {

    char passage[15], quest;

    cout<<“Enter the passage: “;

    cin>>text;

    cout<<“nEnter the quest sort: “;

    cin>>search;

    int compute = 0;

    for(int i=0; passage[i] != ‘’; i++)

    {

    if(text[i] == quest)

    {

    count++;

    }

    }

    if(compute == 0)

    cout<<endl<<search<<” was referable institute.”<<endl;

    else

    {

    cout<<endl<<quest <<” was institute “<<count<<” times”<<endl;

    }

    char moreSearches[15];

    int magnitude = 0;

    for(int i=0; passage[i] != ‘’; i++)

    {

    if(text[i] == quest || passage[i] == ‘-‘)

    continue;

    int subCompute = 0;

    for(int j=0; passage[j] != ‘’; j++)

    {

    if(text[i] == passage[j])

    {

    text[j] = ‘-‘;

    subCount++;

    }

    }

    if(subCompute == compute)

    moreSearches[size++] = passage[i];

    }

    if(magnitude > 0)

    {

    cout<<“The sorts “;

    for(int i=0; i<size; i++)

    {

    cout<<moreSearches[i]<<“, “;

    }

    cout<<” happen the selfselfselfselfsimilar compute of times as “<<search;

    }

    else cout<<“No other sort appears the selfselfselfselfsimilar compute of times as “<<search<<endl;

    return 0;

    }