asked 23.7k views
5 votes
Write a loop that displays all possible combinations of two letters where the letters are 'a', or 'b', or 'c', or 'd', or 'e'. the combinations should be displayed in ascending alphabetical order: aa ab ac ad ae ba bb ... ee

1 Answer

5 votes
for (char first = 'a'; first <= 'e'; first++) {
for (char second = 'a'; second <= 'e'; second++) {
printf("%c%c\\", first, second);
}
}
answered
User Suryavel TR
by
8.3k points