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]
2 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]2 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 unit of measurement that describe the rate that electricity flows through a wire is an
Savatey [412]
AMPERE - a unit of measure for the flow of the current in a circut
8 0
3 years ago
What is the full form of Computer?<br>​
algol13

Answer:

Computer is just made up of hardware and software components.

Explanation:

Sorry if I didn't get your question well

7 0
1 year ago
Rewrite the following condition to avoid a possible arithmetic exception:
dangina [55]

Answer:

if (x > 7 && Math.sqrt(x) < 3)

Explanation:

The previous condition checks if the square root of x is less than 3, but this would raise an error if x is a value equal to or less than 0.

So, the condition checks for the value of x before evaluating the square root after the AND operation to prevent an arithmetic exception.

4 0
2 years ago
Number the steps to describe how Tristan can complete
Lemur [1.5K]

Answer:

  1. Cut the Television and related equipment row.
  2. Click the plus sign on the left side of the table between  the last two rows.
  3. Paste the Television and related equipment row.

Explanation:

In order to move the row, Tristan should first select the row and then cut it. This will ensure that the row will be moved completely instead of copied.

Tristan should then hover with the mouse between the last two rows and click on the plus sign on the left side. It will add a new row to the sheet. between the last two rows.

Tristan should then select the topmost cell and click paste. The television row will be pasted there and Tristan would have successfully moved it.

4 0
3 years ago
Read 2 more answers
Gemima has converted her table to a clustered column
Ber [7]

Answer:

1. Select the table

2. use Ctrl A

3. type the title

3 0
3 years ago
Other questions:
  • One purpose of the dual ignition system on an aircraft engine is to provide for?
    7·2 answers
  • Why might location be important when searching for a job?
    10·2 answers
  • Most keyboards today are in a
    8·1 answer
  • Which of the following is true about a hot site?
    13·1 answer
  • How do i know when someone answered my questions and where can i check what they wrote?
    6·1 answer
  • If you were to design a range of athletic shoes for various sports activities, what key factors would you consider during the de
    11·1 answer
  • How should work be allocated to the team in a Scrum project?
    13·1 answer
  • Potential Energy and Kinetic Energy both mean "energy in motion" True or False​
    8·2 answers
  • Can i have help for a ggogle class room
    15·2 answers
  • When an EC2 instance is being modified to have more RAM, is this considered Scaling Up or Scaling Out?
    5·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!