Respuesta :
Answer: Â
Here it the solution statement: Â
searchResult = strchr(personName, searchChar); Â
This statement uses strchr function which is used to find the occurrence of a character (searchChar) in a string (personName). The result is assigned to searchResult.
Headerfile cstring is included in order to use this method.
Explanation: Â
Here is the complete program
#include<iostream> //to use input output functions Â
#include <cstring> //to use strchr function Â
using namespace std; //to access objects like cin cout Â
int main() { // start of main() function body Â
 char personName[100]; //char type array that holds person name Â
 char searchChar; //stores character to be searched in personName
 char* searchResult = nullptr; // pointer. This statement is same as searchResult  = NULL  Â
 cin.getline(personName, 100); //reads the input string i.e. person name Â
 cin >> searchChar;   // reads the value of searchChar which is the character to be searched in personName Â
 /* Your solution goes here */ Â
 searchResult = strchr(personName, searchChar); //find the first occurrence of a searchChar in personName Â
 if (searchResult != nullptr) //if searchResult is not equal to nullptr Â
 {cout << "Character found." << endl;} //displays character found
 else //if searchResult is equal to null Â
 {cout << "Character not found." << endl;} // displays Character not found Â
 return 0;} Â
For example the user enters the following string as personName Â
Albert Johnson Â
and user enters the searchChar as: Â
J
Then the strchr() searches the first occurrence of J in AlbertJohnson. Â
The above program gives the following output: Â
Character found.
