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

Write a program to perform the following tasks. Define an array of characters of

ID: 3882779 • Letter: W

Question

Write a 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 'at'".

Explanation / Answer

#include<iostream.h>

int main(){

char str[15]; //declaring array with a size of

int count=0; //declaring the dummy value

char search; //declaring the search char for cheacking condition

for(int i=0; i<15; i++){   //iterating the arry

cout<<"Enter the "+i+" charactor in array";

cin >> str[i]; //// assiging the search element by taking the user values

}

cout<<"Please Enter which element you want to search in the array";

cin>>search; // storing the search element by taking the user values

for(int j=0; j<15; j++){ //iterating the arry

if(search==str[i]){ //checking the condition fi the values mathches count will increase to 1

count++;

}

}

cout<<"your element "+search+" repeted in the array is ::"+ count; //displaying the count

}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote