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]
2 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]2 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
The Beaufort Wind Scale is used to characterize the strength of winds. The scale uses integer values and goes from a force of 0,
joja [24]

Answer:

The equivalent if statements is:

ranforce = randi([0, 12]);

if (ranforce == 0)

     disp('There is no wind')

else  if(ranforce>0 && ranforce <7)

     disp('There is a breeze')

else  if(ranforce>6 && ranforce <10)

     disp('This is a gale')

else  if(ranforce>9 && ranforce <12)

     disp('It is a storm')

else  if(ranforce==12)

     disp('Hello, Hurricane!')

end

Explanation:

<em>The solution is straight forward.</em>

<em>All you need to do is to replace the case statements with corresponding if or else if statements as shown in the answer section</em>

4 0
3 years ago
A written document containing a description of a property as of the day of inspection is called a(n) 
meriva
D. An inspection report! Hope this helps!
5 0
3 years ago
Nathan wants to create multiple worksheet containing common formatting styles for his team members. Which file extension helps h
Luden [163]
Templates help Nathan to create multiple worksheets with common styles. He needs to save them with the xls extension.
5 0
3 years ago
Read 2 more answers
What is Boolean algebra
VARVARA [1.3K]

Answer:In mathematics and mathematical logic, Boolean algebra is the branch of algebra in which the values of the variables are the truth values true and false, usually denoted 1 and 0, respectively.

Explanation:

4 0
3 years ago
Read 2 more answers
Develop an algorithm to compute and print out the average of 3 numbers A,B,C​
OLga [1]

Answer:

Input: Take 3 numbers A, B and C

Processing: Find average of 3 numbers using formula: Average= A+B+C/3

Output: The output is Average of three numbers.

Explanation:

We need to write an algorithm to compute and print out the average of 3 numbers A,B,C​

An algorithm has Input, Processing and Output

The algorithm required is:

Input: Take 3 numbers A, B and C

Processing: Find average of 3 numbers using formula: Average= A+B+C/3

Output: The output is Average of three numbers.

3 0
3 years ago
Other questions:
  • I need this ASAP anyone pleas help me i have to do this by tonight
    10·1 answer
  • _____ is defined as an attraction for a source based on a resemblance between the source and receiver of a message.
    15·1 answer
  • A form of speech that is used to clarify, describe, demonstrate, and/or explain is referred to as _____.
    7·2 answers
  • Diagnosing is solving the problem, and troubleshooting is figuring out what the problem is.
    8·1 answer
  • Students enrolled in a digital classroom participate in discussions and take field trips with classmates. watch instructional vi
    11·1 answer
  • Which type of choir often sings AND dances while they perform?
    9·1 answer
  • The HTML tag for the smallest heading is​ what​
    13·1 answer
  • Which are examples of types of audio media that can support a presentation? Check all that apply.
    14·2 answers
  • Which four of the following qualify as fair use?
    11·2 answers
  • Help me pls...
    7·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!