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
ddd [48]
3 years ago
14

c++ 4.17 LAB: Count characters 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. The output should include the input character and use the plural form, n's, if the number of times the characters appears is not exactly 1. Ex: If the input is: n Monday the output is: 1 n
Computers and Technology
1 answer:
Nata [24]3 years ago
5 0

Answer:

#include <iostream>

using namespace std;

int main() {

   int n = 0;

   char c;

   string str;

   cin >> c >> str;

   for (int i = 0; i < str.length(); ++i)

       if (c == str[i]) n++;

   cout << n << " n" << (n > 1 ? "'s" : "");

   return 0;

}

Explanation:

Declares variables n, c, and str.

Next a loop lets count number of character c in string str.

Finally, answer is showing.

You might be interested in
Any device that uses light to read and write information.
Ilya [14]
I think Optical Drive does.
8 0
3 years ago
Read 2 more answers
"The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "
Monica [59]

Question:

"The correct syntax for passing an array as an argument to a method when a method is called and an array is passed to it is: "

A) a[0]..a[a.length]

B) a()

C) a

D) a[]  

Answer:

The correct answer is A.

An example is given in the attachment.

Cheers!

4 0
3 years ago
If you commit license fraud by using an altered or unlawful license:
Scorpion4ik [409]
<h2>Answer:</h2>

All of these

<h2>Explanation:</h2>

If someone is caught with a fake or altered or unlawful driving license, the law will come in action and the person can be sent to jail for it. He may be fined for an amount depending upon the state law. His driving privilege can also be suspended automatically in some states and the false license will be confiscated so that no one could be able to use it again in any circumstances.

5 0
3 years ago
Read 2 more answers
A digital clock on a small cooking appliance keeps time by?
IgorLugansk [536]
They typically use the 50-60 Hz oscillation of AC power or a 32,768 hertz Chrystal oscillator to keep time. <span />
5 0
3 years ago
The motion of any object can be broken down into it's component (parts of) vectors. true or false
Zepler [3.9K]

Answer:

The correct answer choice is true.

8 0
3 years ago
Read 2 more answers
Other questions:
  • A user would like to format an arrow that has been inserted into a chart. What is the most efficient method for completing this
    9·1 answer
  • Which of these is important to consider before believing health or fitness information you find online? Where the information wa
    5·2 answers
  • Assignment 3: Chatbot
    11·2 answers
  • The amount of RAM storage is measured in A: GB The rule of thumb that predicts that CPU capacity will double every 2 years is ca
    11·1 answer
  • Get someone get her for me if need snap kell.c11
    10·1 answer
  • Who plays rocket league on xbox?
    15·2 answers
  • &gt;What is the output of the following code:
    5·1 answer
  • New technology is NOT vital to businesses in which of the following ways?
    7·1 answer
  • Peter has recently bought a media player and a digital camera. He wants to buy a memory card for these devices. Which memory dev
    11·1 answer
  • "kannst du mir bitte helfen" in German-English from Reverso Context: Hier, kannst du mir bitte helfen?
    7·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!