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
grandymaker [24]
3 years ago
5

Write a recursive, bool-valued function, containsVowel, that accepts a string and returns true if the string contains a vowel. A

string contains a vowel if: The first character of the string is a vowel, or The rest of the string (beyond the first character) contains a vowel
Computers and Technology
1 answer:
Tpy6a [65]3 years ago
3 0

Answer:

The method definition to this question as follows:

Method definition:

bool containsVowel (string s1) //define method.  

{

bool value=false; //define bool variable and assign value.

//check conditions.

if (s1.length()==0) //if block

{

   return false; //return value

}

else if (s1[0]=='a'||s1[0]=='e'||s1[0]=='u'||s1[0]=='o'||s1[0]=='i'||s1[0]=='A'||s1[0]=='E'||s1[0]=='U'||s1[0]=='O'||s1[0]=='I') //else if block

{

value=true; //return value.

}

else //else block

{

value = containsVowel(s1.substr(1,s1.length()-1));//calculate value  

return value; //return value.

}

}

Explanation:

In the above code, we define a bool method that is "containsVowel" in this method we pass the string variable that is "s1". Inside a method, we define a bool variable that is "value" and conditional statement that checks in the passed value there is a vowel or not.

  • In if block, we check that pass variable value length is equal to 0. if this condition is true it will return a false value.
  • Then we use else if block in this block we check that if value first letter is vowel to check this condition we use OR logical operator. if this condition is true it will change the variable value that is "true".
  • In the else block we use the value variable that uses the function to check that in passed value there is a vowel if this is true it returns its value.

You might be interested in
What do the points on this website do?
DanielleElmas [232]

Answer:

They allow you to ask more questions and also your rank goes up or down.

Explanation:

5 0
3 years ago
Read 2 more answers
Text box linking is for two or more text boxes in a document, when the text overflows from the first box. Which scenario is the
Julli [10]

Answer:

Explanation:

use the next box i think

8 0
3 years ago
Read 2 more answers
Is windows 7 professional faster than home premium?
Olin [163]
Widows 7 is no longer supported for anti virus, I recommend a windows 10 license
8 0
2 years ago
The operation of early electronic computing devices required:
Harrizon [31]

Answer:

c

Explanation:

5 0
3 years ago
Nina, a programmer, wants to use the programming language Primavera. For which application area should Nina use this language?
AnnyKZ [126]

C. Drawings is the correct answer

8 0
3 years ago
Read 2 more answers
Other questions:
  • To complete a forensic disk analysis and examination, you need to create a ____.
    12·1 answer
  • Implement the function pairSum that takes as parameters a list of distinct integers and a target value n and prints the indices
    11·1 answer
  • The following outline is used to plan a program. What is the name for this type of plan?
    7·2 answers
  • The term “computer literacy” dates back to what decade? <br> 1960s<br> 1970s<br> 1980s<br> 1990s
    5·1 answer
  • You are most likely to use<br> images for photos or digital paintings.
    6·1 answer
  • A network systems administrator would most likely help with
    13·2 answers
  • Mô tả những lợi ích của việc sử dụng đa xử lý không đồng nhất trong một hệ thống di động
    8·1 answer
  • Imagine that you were hired to create the label for a new brand of soup. The client wants to emphasize that the soup has homemad
    10·1 answer
  • Plz show working for binary addition. please solve. 11000 + 110101 + 101011​​
    15·2 answers
  • Which statement about analog and digital images is true?.
    15·1 answer
Add answer
Login
Not registered? Fast signup
Signup
Login Signup
Ask question!