I'm running my code and for some reason when I run with input1 as 15 and input2 as Gary I'm getting the correct If statements as well as the Else statement.
If you are getting the "correct" If statements and the else. What do you need help with?
you are comparing a string like > and <, though they are not numbers so you can't really do that. you can do that to the integer but not the strings. you can only use == or !=.
you are comparing a string like > and <, though they are not numbers so you can't really do that. you can do that to the integer but not the strings. you can only use == or !=.
No the std::string class has overloaded all of the comparison operators, even the greater than and less than operators.
Relational operators perform comparisons on string objects in a fashion similar to the way the strcmp function compares C-strings. One by one, each character in the first operand is compared with the character in the corresponding position in the second operand. If all the characters in both strings match, the two strings are equal. Other relationships can be determined if two characters in corresponding positions do not match. The first operand is less than the second operand if the mismatched character in the first operand is less than its counterpart in the second operand. Likewise, the first operand is greater than the second operand if the mismatched character in the first operand is greater than its counterpart in the second operand.
For example, assume a program has the following definitions:
1 2
string name1 = "Mary";
string name2 = "Mark";
The value in name1 , “Mary,” is greater than the value in name2 , “Mark.” This is because the
“y” in “Mary” has a greater ASCII value than the “k” in “Mark.”
Let me see if I have this right. You have a data set corresponding to the list of the following vocabulary words and numbers in this order:
cold
majority
equal
cereal
bang
leave
Now, each vocabulary word corresponds to a particular set of conditions that have to be met. In other words, a position you would like to start at in the vocabulary list. Then, you want to print out that vocabulary word and the one after it?