Jaya Prakash

Jaya Prakash

  • 2k
  • 131
  • 3.1k

logics programing

Sep 15 2022 5:33 AM

how swap adjacent chars in a given string without using string builder or any method

ex::

input: Tapan

output: atapn like 

This is My Code

Console.WriteLine("enter a string");
string sS = Console.ReadLine();
string sss = "";
int i, j;
for (i = 0; i < sS.Length; i++)
{sss += sS[i + 1];sss += sS[i];
}
Console.WriteLine(sss);

Answers (3)