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
Use the Law of Sines to solve the triangle. Round your answers to two decimal places.
iris [78.8K]

Answer: 37.1

Explanation: The Law of sines states that there is a proportionality between a side of triangle and its correspondent angle, i.e.:

\frac{a}{sinA} = \frac{b}{sinB} = \frac{c}{sinC}

where:

a, b and c are sides

A, B and C are angles

In the question, there is a triangle with 27.4 as a measure of side a, angles A and C. So, it wants the side c:

\frac{a}{sinA} = \frac{c}{sinC}

\frac{27.4}{sin(99.7)} = \frac{c}{sin(20.4)}

c = \frac{27.4.sin(20.4)}{sin(99.7)}

c = 37.1

The side c is 37.1

5 0
3 years ago
Which of the following is an example of a federal tax? A. Social Security tax B. Sales tax C. Property tax D. Transaction tax
Nastasia [14]
Property tax should be the correct answer
6 0
3 years ago
Which is the correct attribute syntax
taurus [48]

ANSWER:  GIVE ME BRAINLIEST AND ILL GIVE YOU THE ANSWER

EXPLANATION: ALL YOU NEED TO DO IS GIVE ME BRAINLIEST FOR THE ANSWER

3 0
3 years ago
At the beginning of Section 5.2, it is stated that multiprogramming and multiprocessing present the same problems, with respect
QveST [7]

Answer:

By definition, <u>multiprocessing</u> refers to the processing of multiple processes at the same time by multiple CPUs.

By definition, <u>multiprogramming</u> keeps programs in main memory at the same time and execute them concurrently utilizing a single CPU doing a context switch.

The first difference is that multiprocessing uses multiple CPUs and multiprogramming to utilize context switch to do concurrency in one CPU. Another difference is that multiprocessing is more expensive but more efficient than multiprogramming due that it allows parallel processing.

6 0
3 years ago
In addition to the cost of legal services and the cost of treatment, which of the following are considered direct costs for work
Mrrafil [7]

Answer:

what are the options for the question

3 0
2 years ago
Other questions:
  • What is computer virus?
    8·1 answer
  • Which option organizes tasks based on importance?
    12·1 answer
  • Assume that play_list refers to a non-empty list, and that all its elements are integers. Write a statement that associates a ne
    7·1 answer
  • Another html/css assignment, drop css code below, thank you
    15·1 answer
  • 1.Input device which transfers information and images from physical documents to computer files.
    14·1 answer
  • A communication medium that carries a large amount of data at a fast speed is called
    6·1 answer
  • Which best explains a password attached to a document?
    6·2 answers
  • What are some applications of computer in public administration?​
    8·1 answer
  • Which of the following is not the disadvantage of closed
    7·2 answers
  • How do i mark brainliest?
    6·2 answers
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!