Register Now

Login

Lost Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

What will be the output of the following C# string? (Enter a String : BOMBAY).
static void Main(string[] args)
{
string Str, Revstr = ” “;
int Length;
Console.Write(“Enter A String : “);
Str = Console.ReadLine();
Length = Str.Length – 1;
while (Length >= 0)
{
Revstr = Revstr + Str[Length];
Length –;
}
Console.WriteLine(“Reverse String Is {0}”, Revstr);
Console.ReadLine();
}

What will be the output of the following C# string? (Enter a String : BOMBAY).
static void Main(string[] args)
{
string Str, Revstr = ” “;
int Length;
Console.Write(“Enter A String : “);
Str = Console.ReadLine();
Length = Str.Length – 1;
while (Length >= 0)
{
Revstr = Revstr + Str[Length];
Length –;
}
Console.WriteLine(“Reverse String Is {0}”, Revstr);
Console.ReadLine();
}
a) BOMBA
b) YABMOB
c) BOMAYB
d) YABMO

Answer: b
Explanation: Explain the concept of reversal of string without using any string inbuilt method but using while loop conditions.

Join The Discussion