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
Usimov [2.4K]
3 years ago
14

Write a program that reads a string and outputs the number of times each lowercase vowel appears in it. Your program must contai

n a function with one of its parameters as a string variable and return the number of times each lowercase vowel appears in it. Also write a program to test your function. (Note that if str is a variable of type string, then str.at(i) returns the character at the ith position. The position of the first character is 0. Also, str.length() returns the length of the str, that is, the number of characters in str.)
Computers and Technology
1 answer:
kogti [31]3 years ago
3 0

Answer:

Here the code is given as follows,

Explanation:

#include <iostream>

#include <string>

using namespace std;

void Vowels(string userString);

int main()

{

   string userString;

   //to get string from user

   cout << "Please enter a string: ";

   getline(cin,userString,'\n');

   Vowels(userString);

   return 0;

}

void Vowels(string userString)

{

   char currentChar;

   //variables to hold the number of instances of each vowel

   int a = 0, e = 0, i = 0, o = 0, u = 0;  

   for (int x = 0; x < userString.length(); x++)  

   {

       currentChar = userString.at(x);

       switch (currentChar)  

       {

           case 'a':

               a += 1;

               break;

           case 'e':

               e += 1;

               break;

           case 'i':

               i += 1;

               break;

           case 'o':

               o += 1;

               break;

           case 'u':

               u += 1;

               break;

           default:

               break;

       }

   }

   // to print no of times a vowels appears in the string

   cout << "Out of the " << userString.length() << " characters you entered." << endl;

   cout << "Letter a = " << a << " times" << endl;

   cout << "Letter e = " << e << " times" << endl;

   cout << "Letter i = " << i << " times" << endl;

   cout << "Letter o = " << o << " times" << endl;

   cout << "Letter u = " << u << " times" << endl;

}

Hence the code and Output.

Please enter a string

Out of the 16 characters you entered.

Letter a = 2 times

Letter e = 1 times

Letter i = 0 times

Letter o = 1 times

Letter u = 0 times.

You might be interested in
(a) If host 192.168.0.1 sends out a packet with source IP address 192.168.0.1 and source port number 3345, after the packets lea
Evgen [1.6K]

Question: The question is incomplete. See the complete question below;

Consider the following situation using NAT (Network Address Translation), where the router uses one public IP address, 138.76.29.7, for several hosts with private IP addresses. The NAT table already has the information as shown due to previous communications.

Answer:

Source IP = 208.38.69.1

Source port = 3006

Explanation:

Network Address Translation (NAT) simply means  the translation of one or more local IP address so as to provide internet access to local hosts. In this case, the router uses one public IP address and with private IP address.

8 0
3 years ago
One benefit for a small business using the hosted software model for its enterprise software is that it can succeed without ____
Simora [160]

Answer:

One benefit for a small business using the hosted software model for its enterprise software is that it can succeed without employing full-time IT professionals.

Explanation:

7 0
2 years ago
Which statement best describes a computer program?
ziro4ka [17]

Answer:

B is the best answer.

Explanation:

All other options listed are related to a program but B beast answers the question.

7 0
2 years ago
What is an ad's target audience composed of
solmaris [256]
C. An ad targets an audience the creators hope will but the product.
3 0
3 years ago
which of these should be reportable diseases to protect public health? A. Obesity B. Diabetes C.Measles D. Lung Cancer
ohaa [14]
It would be measles or obesity
6 0
3 years ago
Read 2 more answers
Other questions:
  • Nadia would like to find text in her current document that differentiates CompanyABC from companyabc. Which option should she us
    8·2 answers
  • A search engine displays a list of webpage names that contain the search text. what is the term for that list?
    14·1 answer
  • Which writing format is also beneficial to public speaking? a. Five paragraph essay c. Conventions b. Prose d. None of these
    5·2 answers
  • The source code of a java program is first compiled into an intermediate language called java ____, which are platform-independe
    8·1 answer
  • Aubrey is on a Windows machine. She wants to back up her Halloween pictures on an external hard drive. Which of the following ta
    12·1 answer
  • What attracts attention and adds spatial depth to a two-dimensional design.
    9·1 answer
  • Write code using the range function to add up the series 99, 98, 97,...
    11·1 answer
  • Which statement describes the relationship between science and technology?
    13·2 answers
  • A customer uses an app to order pizza for delivery. Which component includes aspects of the customer's interaction with an enter
    10·1 answer
  • Hey everyone. I am so bored
    14·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!