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
The process of identifying and eliminating bugs in a software program is most generally called reproducing the problem. diagnosi
sergij07 [2.7K]
The correct answer is Option C

debugging
3 0
3 years ago
Which kind of image is indispensable and needs added text to go with it? A. a map B. a chart C. a graph D. a photograph
Serhud [2]

I'm going to say a chart.  I could be wrong.  If the chart didn't have text with it- how do you know what the chart is for?


A map, it needs text, but these days people just use GPS's.

4 0
3 years ago
Read 2 more answers
What is a template class in c++?
AURORKA [14]
Install Visual Studio 2017 and install the C++ pack and you have access to the templates (function and class)
7 0
3 years ago
A seller buys and item from a manufacturer for 9,500
andriy [413]

we need more info

so we can answer the question

8 0
4 years ago
Is Brainly cheating??
Vanyuwa [196]

Answer: What do you mean?

6 0
3 years ago
Read 2 more answers
Other questions:
  • Whats the relationship between cpu memory and disk​
    10·1 answer
  • Which of the following mountain ranges stretches from Alabama to Canada?
    10·1 answer
  • Which of the following are types of home internet service? Check all that apply
    7·1 answer
  • What are the three modes of the 3D transform manipulator
    12·1 answer
  • What does the regular expression [a-z0-9\-] mean?
    8·1 answer
  • Which entity has the principal responsibility to control the execution of processes?
    14·1 answer
  • All the read/write heads a hard disk are controlled by a(n) ____ which moves the read/write heads across the disk surfaces in un
    13·1 answer
  • Do these devices allow you to view photos using the cloud?
    10·1 answer
  • Decimal numbers is equivalent to binary 110
    5·1 answer
  • What is the biggest problem with technology today?
    10·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!