Hello, I'm trying to create a program that will ask the user to input letters and the program will print the letter in between those 2. Like for example, I enter A and E. How should I go with this? What data type should I use? Loops? Any insight on what logic should I use? functions etc.
Actually this assignment is pretty easy basically here is what you need to do
1)declare 3 characters , input1 , input2 , and a temp variable (temp)
2)ask the user to input two letters (chars) using std::cin (or cin.get() ). cin >> input1;
3) use a loop to iterate starting from a letter after the first until it reaches the last letter you can use a while loop or manipulate a for loop. for( temp = input + 1; temp < input2; ++temp ) cout << temp;
I would do this rather than cin.get() cin >> a >> b;
Then use either a while or for loop to repeatedly:
add 1 to a, and if it is less than b, cout << a;
One problem, if a is greater than b (say a ="F" and b = "A") the result may not be as expected, in that case you could swap the values of a and b before the loop begins.
Ok, last question how does the computer know that A is greater than B or C or D or the other way around? I'm guessing it's not the character codes because A is 65?
EDIT:
AHH I completely messed sorry for this stupid question. I figured it out thanks.