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
kirill115 [55]
3 years ago
13

Write a program whose input is a character and a string, and whose output indicates the number of times the character appears in

the string. Ex: If the input is: n Monday, the output is: Ex: If the input is: z Today is Monday, the output is: Ex: If the input is: n It's a sunny day, the output is Case matters. Ex: If the input is: n Nobody, the output is: n is different than N LAB ACTIVTY 4.12.1: LAB: Count characters 6/10 LAB ACTIVTY 4.12.1: LAB: Count characters 6/10 main.cpp Load default template... 1 #include«iostream» 2 using namespace std; 3 int mainO t 4 5 char C; 6 cin c 8 string s; 9 getline(cin, s); 10 11 int ct-0; 12 13 while (s. find(c) != string ::npos ) { 14 ct ct + 1; 15 s = s, find (c, s. find(c) + 1); 16 17 cout << ct << endl; 18 return 0: Total score: 6/10 Latest submission- 3:56 AM on 04/30/19 Only show failing tests Download this submission 1: Compare output 2/2 Input n Monday Your output 1 2: Compare output 2/2 Input z Today is Monday Your output 0 0/2 : Compare output Output differs. See highlights below. Input n It's a sunny day Your output Expected output2 4: Compare output 0/2 Output differs. See highlights below Input t this is a sentence with many t's Your output Expected output 2/2 5: Compare output Input x X Your output 0
Computers and Technology
1 answer:
-Dominant- [34]3 years ago
6 0

Answer:

Following are the code to the given question:

#include<iostream>//including the header file  

using namespace std;

int count_Characters(char ch, string s)//defining a method count_Characters that holds two variable as a parameter

{

int c=0,i;//defining integer variable

for(i=0;i<s.size();i++)//using for loop to check value

{

   if(s[i]==ch)//use if block to check string and char value

   {

       c=c+1;//incrementing c value

   }

}

return c;//return c value

}

int main() //defining main method

{

char ch;//defining char variable

cin>>ch;//input char value

string s;//defining string variable

cin>>s;//input string value

cout<<count_Characters(ch,s);//calling method count_Characters

return 0;

}

Output:

n Nobody

0

n Monday

1

Explanation:

In this code, a method "count_Characters" is declared that accepts one sting and one char variable as a parameter "s, ch", and inside the method a two integer variable and for loop is declared that uses the if block to match string and char value and increments the c variable value.

In the main method two-variable "s, ch" is declared that inputs the value from the user-end and pass the value into the method, and prints its values.

You might be interested in
What is multimedia computer system​
ivann1987 [24]

A Multimedia can be defined as any application that combines text with graphics, animation, audio, video, and/or virtual reality. Multimedia systems are used for security to keep intruders out of a system and for the protection of stored documents

4 0
3 years ago
after turning the volume all the way up on the speakers you still can't hear any sound which of the following should be your the
ivolga24 [154]

Answer:

check if its pluged in

Explanation:

7 0
4 years ago
1.<br> The correct way to use a seat belt is
Nesterboy [21]

Answer:

4 steps

Explanation:

Step 1: Pull belt across body

Sit in any of your vehicle's seats and secure the three-point harness in its buckle by pulling it across your body.

If the seatbelt is too short, consider an aftermarket restraint and extender. Make sure they meet federal safety standards and are installed professionally.

Step 2: Adjust lower belt

Adjust the lower belt snuggly across your lap and pelvis area – never your stomach.

Pregnant women should wear the lap belt below their belly, not on or above it.

Step 3: Adjust shoulder belt

Adjust the shoulder belt to fit comfortably across the collarbone and chest. It should never rub on your neck or face. Never put the shoulder belt behind your back or under your arm.

Step 4: Check before driving

Check that the belt is secure before driving.

4 0
3 years ago
A vast global network that is made up of many smaller interconnected networks is known as:
Galina-37 [17]

The answer is The Internet.   It is a vast global network that is made up of many smaller interconnected networks. It connects to millions of computer units world wide, in which any computer can communicate with any other computer as long as they are both connected to the Internet. It also made access to information and communication easier.

6 0
4 years ago
Read 2 more answers
What is the purpose of a system call in an operating system?
ikadub [295]

Answer:

 The system call is the programming way for executing the requesting the services in the program from kernel in the particular operating system.

The main purpose of the system call in the operating system is that it basically provide the different types of the services to the users by using the API (Application program interface) system.

It basically provide the interface for allowing the users to request the services between the operating system and a processor. In the linux there are basically three types of system call are as follows:

  • Fork
  • Waitpid
  • Exist

6 0
3 years ago
Other questions:
  • Write a program FindDuplicate.java that reads n integer arguments from the command line into an integer array of length n, where
    11·1 answer
  • Which of the following might not exist in a URL?
    10·2 answers
  • in cell h5, enter a formula that will calculate the percentage of attendees that went to the Altamonte springs job fair in 2018.
    15·2 answers
  • What two methods can be used to access and modify an existing program that is running on an iot device in cisco packet tracer? (
    6·1 answer
  • Which statement describes part of the meeting scheduling process? It is always an all-day event. It is created in a single calen
    14·1 answer
  • Discuss the importance of top management commitment and the development of standards for successful project management. Provide
    10·1 answer
  • Would a hurricane form if the humidity is really high and the breeze is very low
    11·1 answer
  • If a switch needs to send information to other switches in the network it would send out a ___________.
    7·2 answers
  • PLEASE HELP THIS IS CONFUSING ME
    8·2 answers
  • Anyone know how to do Calculator program in python ?
    14·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!