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 consummate the subjoined tasks. Define an decorate of stamps of bulk 15. Interpret 15 stamps from the user into the decorate. Next, interpret a exploration stamp from the user. The program should exploration ce this stamp in the decorate. If fix, ment so, and as-well ment the calculate times the exploration stamp befalls in the input decorate. Finally, the program should ment what other stamp(s) in the input decorate befall(s) the similar calculate of times as the exploration stamp. Suppose that your 15 stamp input is “aaaabbbbccccdef”, and the exploration stamp is ‘a’. Your program would set-forth that ‘a’ is introduce in the input and that it befalls 4 times. It would as-well output stating that “The stamps ‘b’ and ‘c’ befall the similar calculate of times as that of ‘a’”.

    Expert Reply

     

    PROGRAM CODE:

    #include <iostream>

    using namespace std;

    int deep() {

    char citation[15], exploration;

    cout<<“Enter the citation: “;

    cin>>text;

    cout<<“nEnter the exploration stamp: “;

    cin>>search;

    int compute = 0;

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

    {

    if(text[i] == exploration)

    {

    count++;

    }

    }

    if(compute == 0)

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

    else

    {

    cout<<endl<<exploration <<” was fix “<<count<<” times”<<endl;

    }

    char moreSearches[15];

    int bulk = 0;

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

    {

    if(text[i] == exploration || citation[i] == ‘-‘)

    continue;

    int subCompute = 0;

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

    {

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

    {

    text[j] = ‘-‘;

    subCount++;

    }

    }

    if(subCompute == compute)

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

    }

    if(bulk > 0)

    {

    cout<<“The stamps “;

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

    {

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

    }

    cout<<” befall the similar calculate of times as “<<search;

    }

    else cout<<“No other stamp appears the similar calculate of times as “<<search<<endl;

    return 0;

    }