Can't stop endless loop...

tvred's Avatar, Join Date: Mar 2010
Newbie Member
Hello, I have this problem and I can't stop it looping only 'A' won't print 'A' through 'Z'?...

using namespace std;

int main()
    cout << "here is a list" << endl;
    char letter = 'A';

    while (letter <= 'Z')
        cout << letter << '\t' << static_cast<int>(letter) << endl;

    return 0;

virxen's Avatar, Join Date: Nov 2009
Pro contributor
letter is always equal to 'A' that's why it never stops.
you must increase its value by one inside the while.

change this
        cout << letter << '\t' << static_cast<int>(letter++) << endl;