1. In the code editor, you are provided with a main() function that asks the user for 2 characters, passes these characters to a function call of the getHigherValue() function, and then prints out the ASCII value of the higher character. 2. Your task is to implement the getHigherValue function which has the following details: Return type - int Name - getHigherValue Parameters - 2 characters to be compared Description - the ASCII value of the higher character. 3. Hint: Comparing characters in C++ is just like comparing integers. 4. DO NOT EDIT ANYTHING IN THE MAIN Input 1. First character 2. Second character This is the given code: #includeusing namespace std; int main() { char a, b; cout << "Enter first character: "; cin >> a; cout << "Enter second character: "; cin >> b; cout << "Result value = " << getHigherValue(a, b); return 0; }
The Answer to the Question
is below this banner.
Can't find a solution anywhere?
NEED A FAST ANSWER TO ANY QUESTION OR ASSIGNMENT?
Get the Answers Now!You will get a detailed answer to your question or assignment in the shortest time possible.
Here's the Solution to this Question
#include <iostream>
using namespace std;
int getHigherValue(char a, char b)
{
int x;
x = int(a);
if(a > b) x = int(a);
if(a < b) x = int(b);
return(x);
}
int main()
{
char a, b;
cout << "Enter first character: ";
cin >> a;
cout << "Enter second character: ";
cin >> b;
cout << "Result value = " << getHigherValue(a, b);
return 0;
}