17.9.15

letter with loop c++

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

Solution:

for (char outerChar='a'; outerChar<='e'; outerChar++)
    for (char innerChar='a'; innerChar<='e'; innerChar++)
        cout << outerChar << innerChar << "\n";

1 comment:

  1. ID #201611036
    Link--> https://drive.google.com/open?id=1WNSox5zda68pYaJh33_KdyAdjR1tE98W

    ReplyDelete

Comment Here