Question

Write a C++ function that has a parameter of char type. The function returns true if...

Write a C++ function that has a parameter of char type. The function returns true if the character is ‘Y’ or ‘y’, and returns false if the character is ‘N’ or ‘n’. You are not allowed to use any pre-defined function.

0 0
Add a comment Improve this question Transcribed image text
Answer #1

\small \color{blue}Answer:\;\;

bool checkYes(char ch) {
    if (ch == 'Y' || ch == 'y')
        return true;
    else
        return false;
}
Add a comment
Know the answer?
Add Answer to:
Write a C++ function that has a parameter of char type. The function returns true if...
Your Answer:

Post as a guest

Your Name:

What's your source?

Earn Coins

Coins can be redeemed for fabulous gifts.

Not the answer you're looking for? Ask your own homework help question. Our experts will answer your question WITHIN MINUTES for Free.
Similar Homework Help Questions
  • Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[],...

    Write in C language 5. [8] Write a function with prototype » void string_copy(const char source[], char destination[], int n); This function copies string source to string destination. Parameter n represents the size of array destination. If the latter array is not sufficiently large to hold the whole source string then only the prefix of the string which has room in the latter array should be copied. Note that after copying, the null character should also be included to mark...

  • a. Ask the user for the input of a letter (char type). Write a function that...

    a. Ask the user for the input of a letter (char type). Write a function that takes a char as the argument (parameter) and returns the ASCII value of that char back to the caller. Call the function using the char variable and taking input from the user (no validation required). Display the value in ASCII. b. Write a program that takes a char as the argument (parameter) and uses a loop to interrogate the char, calling a function that...

  • In C++, write a function isOdd() that takes one integer parameter. The function returns true if...

    In C++, write a function isOdd() that takes one integer parameter. The function returns true if the number if odd and false otherwise.

  • 1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if...

    1.1. Write a function named "areFirstTwoTheSame AsLast TwoChars" that accepts a string. It returns true if the first two characters and the last two characters of the string are the same. It returns false otherwise. In addition, if the string is empty or has only one character, it also returns false. For example, these are the strings with their expected return values false falsc "AB" true "ABA" false "ABAB" trus "ABBA" false "ABCABC false "ABCCAB" true 1.2 Write a function...

  • Write in c++ and has to be used to gtest. Problem 4: Write a function contains...

    Write in c++ and has to be used to gtest. Problem 4: Write a function contains (char*, char) which returns true if the 1st parameter of entered string contains the 2nd parameter char contains the value from the string, or false otherwise.

  • Write a program that write a value-returning function, isVowel, that returns the value true if a...

    Write a program that write a value-returning function, isVowel, that returns the value true if a given character is a vowel and otherwise returns false. You must insert the following comments at the beginning of your program and write our commands in the middle: Write a C++ Program: /* // Name: Your Name // ID: Your ID */ using namespace std; #include <iostream> using namespace std; bool isVowel(char ch); int main() {     char ch;     …     …         ...

  • C ++Write a function, anyThree (int a[], int n), that returns true if the value 3...

    C ++Write a function, anyThree (int a[], int n), that returns true if the value 3 appears in the array exactly 3 times, and no 3's are next to each other. The parameter n will be greater than or equal to 0. Write a function, anyThree (int all, int n), that returns true if the value 3 appears in the array exactly 3 times, and no 3's are next to each other. The parameter n will be greater than or...

  • Write a function called smallestLetter that takes in a string argument and returns a char. The...

    Write a function called smallestLetter that takes in a string argument and returns a char. The char that is returned by this function is the character in the string with the lowest ASCII integer code. For example: smallestLetter("Hello") returns ‘H’ which is code 72, and smallestLetter("Hello World") returns ‘ ’ (The space character) which is code 32

  • C++ Write a function sleepIn with two parameters 'weekday' and 'vacation'. The parameter 'weekday' is True...

    C++ Write a function sleepIn with two parameters 'weekday' and 'vacation'. The parameter 'weekday' is True if it is a weekday, and the parameter 'vacation' is True if we are on vacation. We sleep in if it is not a weekday or we're on vacation. Return True if we can sleep in. function prototype: bool sleepIn(bool weekday, bool vacation): Function Call Function Returns sleepIn(false, false); true OK      sleepIn(true, false); false OK      sleepIn(false, true); true OK      sleepIn(true, true);...

  • sorted vowels Write a function that returns true if the vowels in the input string A...

    sorted vowels Write a function that returns true if the vowels in the input string A appear in non-decreasing order and false otherwise. You can assume this function is not case sensitive. If the string does not contain any vowels, it must return true. bool sorted_vowels (const char A)

ADVERTISEMENT
Free Homework Help App
Download From Google Play
Scan Your Homework
to Get Instant Free Answers
Need Online Homework Help?
Ask a Question
Get Answers For Free
Most questions answered within 3 hours.
ADVERTISEMENT
ADVERTISEMENT
ADVERTISEMENT