Ask Question
26 February, 07:29

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: For example, if last was initialized to 'c' the output should be aa

+4
Answers (1)
  1. 26 February, 07:54
    0
    for (char i='a'; i<='e'; i++) {

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

    cout << i<< j<< "/n";

    }

    }

    Explanation:

    The loop runs all characters from the inner while the outer holds one character, by doing so, a will be matched with a, b, c, ... Like wise b, c, d, ... and on it goes.
Know the Answer?
Not Sure About the Answer?
Find an answer to your question 👍 “Given an char variable last that has been initialized to a lowercase letter, write a loop that displays all possible combinations of two ...” in 📗 Computers & Technology if the answers seem to be not correct or there’s no answer. Try a smart search to find answers to similar questions.
Search for Other Answers