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
Explain why blocking ping (ICMP echo request) packets at an organization's edge router is not an effective defense against ping
tresset_1 [31]

Answer:

The blocking ping is not effective in an organization because it may required ping echo message from some trusted system. the best method will be to do the filtering of incoming echo ICMP messages.

In systems we have ping utility, that is based on ICMP protocol. Its function is  to check the end to end connectivity of the system.

In this case a  fist all an echo ICMP message is send to the host then host reply with ICMP message. to defend yourself from this flood attack, we need to filter the incoming echo ICMP packet messages. a net filter can be used to achieve it.

The best method be to applied is the firewall having a net filter with limit setting or any intrusion system. In market we have various firewall and intrusion system available to do so.

Explanation:

Solution

Ping Flood Atack:

In this attack the main of the attacker is to saturate the system with ICMP for example (internet control message protocol) traffic. as you have saturated the system, it will have less CPU time to serve others.

Defence against this attack:

In our systems we have ping utility, that is based on ICMP protocol. Its used to check the end to end connectivity of the system. here fist all an echo ICMP message is send to the host then host reply with ICMP message. to defend yourself from this flood attack , we need to filter the incoming echo ICMP packet messages. a Net filter can be used to achieve this.

The best way will be to used the firewall having net filter with limit setting or any intrusion system. In market we have various firewall and intrusion system available to do so.

Blocking ping packets to avoid ping flood attack:

Its not a good approach to block ping packets. because you may required ping echo message from some trusted system. The best option will be to do the filtering of incoming echo ICMP message.

6 0
4 years ago
System uses a 6-bit 2’s complement signed integer representation. What is the range of decimal values it can represent?
kap26 [50]

Answer:

-32 to +31

Explanation:

6 bit 2s complement representation will be of the form b1b2b3b4b5b6 where each bit is either 0 or 1.

The largest positive number that can be represented using this scheme is 011111

Translating this to decimal this is 1*2^4 + 1^2^3 + 1^2^2 + 1^2^1 + 1^2^0

=16 + 8 + 4 + 2 + 1 =31

The smallest negative number that can be represented using this scheme is 100000

Translating this to decimal = -1 * 2^5 = -32

So the range of decimal values that can be represented is -32 to +31.

6 0
3 years ago
Your desktop computer monitor is not displaying a picture. What would you do to troubleshoot the problem?
vichka [17]
I would have to say B but if you don't fell like thats the answer then A I'm not 100% sure
4 0
3 years ago
Read 2 more answers
How can presentation software be used in a
atroni [7]

Answer:

to compose letters and memos

to create charts and graphs from a table of

values

to deliver a sales presentation to clients

Explanation:

I forget what the reasoning behind them but I know this is the answer

7 0
3 years ago
Read 2 more answers
You need to store product quantities, and you want to minimize the amount of storage space that is used. Which data type should
Inga [223]

Answer:

win-RAR or other kind of compactor

Explanation:

Also you may use Cloud or Dropbox

7 0
3 years ago
Other questions:
  • Convot the following biliary number into decimal form using any method ? (1010.100)2
    8·1 answer
  • Is the protocol that specifies how web browsers and servers communicate.?
    11·1 answer
  • According to the article words have the power to change people's behavior. Describe one example of this from the article
    6·1 answer
  • According to the chart, which degree would you have to earn in order to make the most amount of money? A bar graph titled Averag
    13·2 answers
  • If a user cut a section from a photograph where is the cut sections location
    10·1 answer
  • You open a link in a new tab by holding the _______ button while clicking the link
    8·1 answer
  • Sally needs to teach her class how to convert a decimal number to a binary number. What is the first step she should take to sta
    5·1 answer
  • You can use this area to create your resume.
    12·1 answer
  • Write a program that reads in a text file, infile.txt, and prints out all the lines in the file to the screen until it encounter
    15·1 answer
  • 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!