Then you need to use arrays. A char array that has every single letter in it.
char letters[27] = {'A', 'B', 'C'....}
Then you have to check if any of the inputed letters, match two of the letters inside the array.
And then print out everything between those 2 letters.
Is there another way to do it? I know there has to be a for loop somewhere in the program because that much was given by the professor. And we haven't gone over arrays yet in class, so I doubt he'd want us to use one.
// ------------------------------------------------------------------
// Function: Read in two letters.
// Display the sequence from the first letter to to last.
//
// Examples: input A C ==> output: A B C :
// input A A ==> output: A :
// input Z A ==> output: :
//
// WARNING: DO NOT PROMPT FOR INPUT.
// ------------------------------------------------------------------
#include <iostream>
usingnamespace std;
int main()
{
char letter;
for
{
cout << letter << ' '; // DO NOT DELETE.
}
cout << ':' << endl; return 0; // DO NOT MODIFY, MOVE or DELETE.
}
#include <iostream>
usingnamespace std;
int main()
{
char first, last;
cin >> first >> last;
for (int i = first; i < last; i++)
{
cout << letter << ' '; // DO NOT DELETE.
}
cout << ':' << endl; return 0; // DO NOT MODIFY, MOVE or DELETE.
}
Apparently they cant use arrays @obscure. And it also says no prompt for input, so they cant use cin either...
Ah ... ! I don't noticed about the arrays .. Sorry ..
So (steezedq) pick the (Faison) solution because it doesn't contain an array ..
Second thing about the prompt ... maybe he mean to not use a ( message)
before (cin) ..
Because there is no why other than (cin) to read input ( for him ) ..