Home > Blockchain >  Print every two letters using substring and for loops
Print every two letters using substring and for loops

Time:12-09

I have a trouble using substring function here. Below, i used remove function. But i wanna (want to) use substring function. Can you give me a hint?

  1. Enter a phrase: ABCDEFGH

Output:

GH

EFGH

CDEFGH

ABCDEFGH

CodePudding user response:

I wrote a central part for you, you will have to write an user interface and user input validation

    var phrase = "ABCDEFGH";
    int i;
    for (i=phrase.Length-2; i >=0; i-=2) Console.WriteLine(phrase.Substring(i));
    if (i == -1) Console.WriteLine(phrase);
  • Related