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
Breaking down a problem to find the solution is called:
velikii [3]
I would say B.......
7 0
3 years ago
Lots of data can be transferred in short time, when we have,
dusya [7]

Answer: B. Higher Bandwidth

8 0
2 years ago
Read 2 more answers
A short
alexandr402 [8]

Explanation:

Java Bitwise Operators

Operator Description Example

>> (right shift) Binary Right Shift Operator. The left operands value is moved right by the number of bits specified by the right operand. A >> 2 will give 15 which is

8 0
3 years ago
COULD U ANSWER THIS ???
vladimir1956 [14]

Answer:

B.lightning striking a tree

Explanation:

The crowd dispersing in all directions is not a closed-loop by any means, and students jogging around an oval track as well is not a closed-loop, and also not a cross country run from one point to another. However, the lightning striking a tree is a closed loop that best models a circuit. And as lightning strikes the tree, like a closed circuit, tree catches the fire, or in circuitry words, the current is generated, and tree catches the fire due to it, just like bulb starts glowing.

3 0
3 years ago
Which types of charts are examples found in Excel? Check all that apply.
marysya [2.9K]

Answer: 1,2,4,5,6

Explanation:

columns

bar

histogram

pie

scatterplot

5 0
2 years ago
Other questions:
  • What is the importance of using the proper markup language?
    8·2 answers
  • Which functions are performed by server-side code??​
    10·1 answer
  • What is the relationship between ionic bonds and cleavage
    13·1 answer
  • Trish has bought a new computer that she plans to start working on after a week. Since Trish has not used computers in the past,
    10·1 answer
  • When you park on a hill, think about which way _____.
    6·2 answers
  • The operating system provides a ____, which is the means with which you interact with the computer
    5·1 answer
  • High-end tools in project management software have enterprise and _____ functions that summarize and combine individual project
    9·1 answer
  • How do u type faster
    5·1 answer
  • . What process skill would a scientist use to find the length of a line
    5·1 answer
  • Task 2
    13·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!