Not logged in. Log in with GitHub. About Websheets.

List of all available Websheets


Viewing cpp/functions/is-vowel by redekopp@usc.edu. You have unsaved changes. Log in above to create, edit, preview and publish Websheets.
PropertyValue
Description
html markup
shown to student
 
<p>Write a function, <tt>isVowel</tt> to check if a character is a vowel (of either case) and return <tt>true</tt> or <tt>false</tt> accordingly.</p> 
<p>See if you can utilize the function, <tt>isLowerVowel</tt>, that you wrote in a previous exericse to help implement the bigger function, <tt>isVowel</tt>.</p>
<p></p>
<p>Recall <tt>char tolower(char c)</tt> is available in the <tt><cctype></tt> library.</p>
   
Public permissions remove
Remarks
Comments, history, license, etc.
 
Copied from problem cpp/functions/is-lower-vowel (author: redekopp@usc.edu)
Copied from problem cpp/functions/abs_func (author: redekopp@usc.edu)
remove
Engine
Template / Reference solution
 
#include <iostream>
#include <iomanip>
using namespace std;
bool isLowerVowel(char c);
bool isVowel(char c);
// return true if the c is a vowel
bool isVowel(char c) 
{
\[
   return isLowerVowel(c) || isLowerVowel(tolower(c));
]\
} 
// return true if c is a lower-case vowel
bool isLowerVowel(char c) 
{
\[
   return c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u';
]\
} 
// test it
int main() {
   // Should return true
   cout << boolalpha << isVowel('a') << endl;
   cout << boolalpha << isVowel('e') << endl;
   cout << boolalpha << isVowel('i') << endl;
   cout << boolalpha << isVowel('o') << endl;
   cout << boolalpha << isVowel('u') << endl;
   cout << boolalpha << isVowel('A') << endl;
   cout << boolalpha << isVowel('E') << endl;
   cout << boolalpha << isVowel('I') << endl;
   cout << boolalpha << isVowel('O') << endl;
   cout << boolalpha << isVowel('U') << endl;
   // Should return false
   cout << boolalpha << isVowel('b') << endl;
   cout << boolalpha << isVowel('z') << endl;
   return 0;
}
C++ test suite
json list of stdin/args tests
e.g. [{"stdin":"hi", "args":["4", "5"]},
{"stdin":"noargs"}]

to just run once with no input use [{}]
 
[
   {}
]
Solution visibility remove
Remove default compiler flag(s)
json list of flags
see default_cppflags
e.g. ["-Wno-write-strings"]
 
["-Wconversion"]
remove


Optional properties:

Note: problems are open-source by default (see 'Public permissions'). Assumed license for open problems is Creative Commons 4.0 Attribution-ShareAlike unless specified in 'Remarks'.