1answer.
Ask question
Login Signup
Ask question
All categories
  • English
  • Mathematics
  • Social Studies
  • Business
  • History
  • Health
  • Geography
  • Biology
  • Physics
  • Chemistry
  • Computers and Technology
  • Arts
  • World Languages
  • Spanish
  • French
  • German
  • Advanced Placement (AP)
  • SAT
  • Medicine
  • Law
  • Engineering
n200080 [17]
4 years ago
12

Assign searchResult with a pointer to any instance of searchChar in personName.

Computers and Technology
1 answer:
Artyom0805 [142]4 years ago
8 0

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.

You might be interested in
Public static double secret(int first, double second)
gizmo_the_mogwai [7]

Answer:

d. double temp;

Explanation:

Given

The above code segment

Required

Which is not part of the method definition

The method in the above program is:

public static double secret(int first, double second)

Looking through the options, we can conclude that:

d. double temp;

..... is not a part of the method

6 0
3 years ago
Which of the following countries have mixed-market economy
timurjin [86]

Answer:

B

Explanation:

An economic system in which both the private enterprise and a degree of state monopoly (usually in public services, defense, infrastructure, and basic industries) coexist. All modern economies are mixed where the means of production are shared between the private and public sectors. Also called dual economy.

6 0
3 years ago
Select all that apply.
professor190 [17]
Social worker and legal aid worker

4 0
3 years ago
Read 2 more answers
Which cell formatting is most likely to use $?
TiliK225 [7]
Currency is the correct answer
4 0
4 years ago
Read 2 more answers
Write a lottery program that will ask the user if they would like to pick 5 numbers (1-30) or if they would like to choose EZ Pi
Llana [10]

Answer:

Explanation:

The following code is written in Python and creates arrays for the user's numbers and the next chance numbers, it also creates a cost variable and a did_you_win variable. The function takes in the winning numbers as an array parameter. It asks all the necessary questions to generate data for all the variables and then compares the user's numbers to the winning numbers in order to detect if the user has won. Finally, it prints all the necessary information.

import random

def lottery(winning_numbers):

   user_numbers = []

   next_chance_drawing = []

   cost = 0

   did_you_win = "No"

   #print("Would you like to choose your own 5 numbers? Y or N")

   answer = input("Would you like to choose your own 5 numbers? Y or N: ")

   if answer.capitalize() == "Y":

       for x in range(5):

           user_numbers.append(input("Enter number " + str(x+1) + ": "))

   else:

       for x in range(5):

           user_numbers.append(random.randint(0,31))

           cost += 1

   next_chance = input("Would you like to enter a Next Chance drawing for $1.00? Y or N: ")

   if next_chance.capitalize() == "Y":

       for x in range(4):

           next_chance_drawing.append(random.randint(0, 31))

           cost += 1

           

   if user_numbers == winning_numbers or next_chance_drawing == winning_numbers:

       did_you_win = "Yes"

   print("User Numbers: " + str(user_numbers))

   print("Next Chance Numbers: " + str(next_chance_drawing))

   print("Cost: $" + str(cost))

   print("Did you win: " + did_you_win)

6 0
3 years ago
Other questions:
  • Information technology is the study of managing, processing, and retrieving information.
    5·1 answer
  • How do humans feel about being abducted?
    12·2 answers
  • Once you have selected the range of cells for your table data, from which tab can you open the Insert Table dialog box?
    6·2 answers
  • Grbn kmjnhbgvfcdxswikmjnthbrvgt
    5·2 answers
  • List and describe four communication tools that are currently popular.
    9·1 answer
  • What is an online recommendation engine?
    12·1 answer
  • Write the definition of a method min that has two int parameters and returns the smaller.
    9·1 answer
  • In the context of computer and network security, _____ means that a system must not allow the disclosing of information by anyon
    10·1 answer
  • AJ created a list, and he needs all of the numbers to be in order. Which Python function will allow him to organize his list num
    5·2 answers
  • 15. Virus cannot infect files that are saved in i. USB ii. CD-ROMs iii. Memory card iv. All of them​
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!