20.9k views
0 votes
Given an char variable last that has been initialized to a lowercase letter, write a loop that displays all possible combinations of two letters in the range 'a' through last. The combinations should be displayed in ascending alphabetical order:

1 Answer

6 votes

Answer:

for (char outerChar='a'; outerChar<='e'; outerChar++){

for (char innerChar='a'; innerChar<='e'; innerChar++){

cout << outerChar << innerChar << "\\";

}

}

User Asatur Meltonyan
by
4.5k points