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 location on the Word screen where text will be entered is known as the _____.
mixas84 [53]
Insertion point is represented by blinking vertical line
4 0
3 years ago
20 points
adoni [48]
Yes it's important. It's like taking jotting down the ideas you have for a project, you don't want to forget anything, and these things help you keep track of what you want to do.

Answer would be false.
4 0
3 years ago
I just downloaded this song and if any one wants to listen to it then go ahead and do that. It’s called Trap Music 2018 âa bass
xz_007 [3.2K]

Answer:

ok

Explanation:

4 0
2 years ago
Read 2 more answers
Please solve in 5 mins very fast​
Dmitriy789 [7]

Answer:

a. virtual reality

b. Master Boot Records

c. Primary function of a router

d. zoom

Explanation:

4 0
3 years ago
Read 2 more answers
) The order of messages on a sequence diagram goes from _____. (Points : 6)
Alla [95]

Answer:

Top to bottom

Explanation:

A sequence diagram shows the sequence or the order in which the interaction between components takes place.

It places them in order of the occurrence of the events or interactions between the components or objects thus arranging these from top to bottom.

The sequence diagram shows the way an object in a system functions and the order it follows.

3 0
3 years ago
Other questions:
  • 1.Which type of camera tool pushes the picture back and makes it wider, exaggerating the distance between the background and for
    13·2 answers
  • Kyra needs help planning what images and text to use in her web page what technique can help her
    5·2 answers
  • It is illegal to have __________ emergency lights on your vehicle.
    6·2 answers
  • Click cell C6 in the Data worksheet and insert a column. Type Series Name in cell C6. Click cell C7 in the Data worksheet and in
    9·1 answer
  • When parking on hills or an unlevel surface, make sure your_____is
    15·2 answers
  • Retype and run, note incorrect behavior. Then fix errors in the code, which should print num_stars asterisks.
    9·1 answer
  • What command is most effective at identifying different types of files?
    6·1 answer
  • Complete each sentence using the drop-down menu. Information on local driving laws can be found on a website. A class textbook c
    9·2 answers
  • ASAP BRAINLIEST!!!
    10·1 answer
  • What is the function of ALU? <br>​
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!