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
When the user types into a Textbox control, the text is stored in the control's __________ property.
joja [24]

The property that stores the text a user types into a Textbox is called the: control's text property.

<h3>The Textbox Control</h3>

The Textbox Control is employed in display a text or accept the text as an input from a user. Also, single line of text can be accepted as input at runtime from a VB.NET Windows.

The text that displays on the Textbox can also be set. The control's text property therefore stores the text a user types into Textbox.

In conclusion, the property that stores the text a user types into a Textbox is called the: control's text property.

Learn more about Textbox Control on:

brainly.com/question/5677552

3 0
2 years ago
Sally needs to copy data from the first worksheet to the fifth worksheet in her workbook. Which combination of keys will she use
Marta_Voda [28]

To make things faster, instead of using your mouse to navigate multiple Microsoft Excel sheets that are in the same document, you can use a shortcut instead. This is what Sally will be doing to copy data from her first worksheet to the fifth.

The shortcut function that Sally needs to use to achieve this is (A) Ctrl and Page Up or Page Down Keys.

7 0
2 years ago
Read 2 more answers
Which graphics format works best for desktop publishing and print work? (1 point) .tiff .gif .tga .jpeg?
Sergeeva-Olga [200]
. jpeg, probably works best
6 0
2 years ago
Which U.S. government agency first funded the development of the Internet?
Doss [256]

Answer: ARPANET

Explanation: The first workable prototype of the Internet came in the late 1960s with the creation of ARPANET, or the Advanced Research Projects Agency Network. Originally funded by the U.S. Department of Defense, ARPANET used packet switching to allow multiple computers to communicate on a single network.

7 0
3 years ago
Read 2 more answers
What is the relationship between CAD and CIM ?
Marat540 [252]
<span> CAM( computerised Aided Manufacture) is when you have workers being helped by computerised tools, CIM (computerised intergated manufacture) is when the whole process is computerised, in manufacture this usually uses robotic arms. These can manufacture 24/7 in needed, they can work very accurately ( they are faster and stronger than a human arm) </span>
5 0
3 years ago
Read 2 more answers
Other questions:
  • Dr. Patterson’s office calls to give patient Sara Martin her test results from her most recent visit. Her husband answers the ph
    8·2 answers
  • What is one problem you should keep in mind when researching information on the Internet?
    6·2 answers
  • Is it safe to take apart a computer monitor?
    13·1 answer
  • A DESKTOP COMPUTER (NAMED WORKSTATION22) CAN'T CONNECT TO THE NETWORK. A NETWORK CARD WAS PURCHASED WITHOUT DOCUMENTATION OR DRI
    14·1 answer
  • Which of these statements makes the most sense? a folder is contained within a file. a file is contained within a folder. a driv
    9·2 answers
  • Write a method for the Customer class that that will return a string representing a bill notice when passed a double value repre
    14·1 answer
  • For the following C code assume k and m are passed in x3 and x4 respectively, while result is returned in x4. Compile this code
    14·1 answer
  • How does applying Fontworks effects to text on an advertising flyer change the text?
    14·2 answers
  • Write a program named as reverse.c that reads a message, then prints the reversal of the message. The output of the program shou
    7·1 answer
  • The average American has 10 devices, ask for users average number of devices. Any number between 7 and 12 will print “you have a
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!