Interviews33 answers
Print hello world as Olleh Dlrow ?
33 Answers
String result = “hello world”;
For( int i = result.length-1 ; i>=0 ; i- -)
{
Console.writeline( result[i]);
}
Rajani PandeyPosted Jan 7, 2018, 8:02 AM EST
class Program
{
static string sk = null;
static void Main(string[] args)
{
sk = "hellO worlD";
string[] s1 = sk.Split(' ');
string s2 = s1[0];
string s3 = s1[1];
char[] d1 = s2.ToCharArray();
Array.Reverse(d1);
Console.Write(d1);
Console.Write(" ");
char[] d2 = s3.ToCharArray();
Array.Reverse(d2);
Console.WriteLine(d2);
Console.ReadLine();
}
}
Sudhakar PatilPosted Apr 6, 2017, 9:25 AM EDT
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Helloworldrv
{
class Program
{
static string sk = null;
static void Main(string[] args)
{
sk = "Hello World";
char[] charArray = sk.ToCharArray();
Array.Reverse(charArray);
Console.WriteLine(charArray);
Console.ReadLine();
}
}
}
Sudhakar PatilPosted Apr 6, 2017, 9:10 AM EDT
public static string Foo(string data, string seperator)
{
return string.Join(seperator, data.Split(new string[] { seperator }, StringSplitOptions.RemoveEmptyEntries)
.Select(x => new string(x.Reverse().ToArray())).Select(y => y.ToLower().Replace(y.Substring(0, 1), y.Substring(0, 1).ToUpper())));
}
Anas PKPosted Jan 16, 2017, 3:49 AM EST
string strInput = "hello world";string strOutput = string.Join(" ", strInput.Split(' ').Select(y => new String(y.Reverse().ToArray())));Console.WriteLine(strOutput);Console.ReadLine();
Ramesh SPosted Nov 24, 2016, 2:14 AM EST
string str = "hello world";
string rvrse = "";
string rvrse1 = "";
string[] obj = str.Split(' ');
string s1 = obj[0];
string s2 = obj[1];
for(int i = obj[0].Length-1;i>=0;i--)
{
rvrse = rvrse + s1[i];
}
for(int j = obj[1].Length-1;j>=0;j--)
{
rvrse1 = rvrse1 + s2[j];
}
string chk = rvrse.First().ToString().ToUpper() + rvrse.Substring(1);
string chk1 = rvrse1.First().ToString().ToUpper() + rvrse1.Substring(1);
Console.WriteLine(chk +" "+ chk1);
sumen bhattacharyaPosted Oct 24, 2016, 10:12 PM EDT
string str = "hello world";
string rvrse = "";
string rvrse1 = "";
string[] obj = str.Split(' ');
string s1 = obj[0];
string s2 = obj[1];
for(int i = obj[0].Length-1;i>=0;i--)
{
rvrse = rvrse + s1[i];
}
for(int j = obj[1].Length-1;j>=0;j--)
{
rvrse1 = rvrse1 + s2[j];
}
string chk = rvrse.First().ToString().ToUpper() + rvrse.Substring(1);
string chk1 = rvrse1.First().ToString().ToUpper() + rvrse1.Substring(1);
Console.WriteLine(chk +" "+ chk1);
sumen bhattacharyaPosted Oct 24, 2016, 10:11 PM EDT
Sub Main()
Dim inputString As String = "Hello World"
Dim result = String.Join(" ", inputString.Split(" ").Select(Function(x) StrConv(String.Join("", x.Reverse().ToArray()), VbStrConv.ProperCase)))
Console.WriteLine(result)
Console.ReadLine()
End Sub
Somesh SrivastavaPosted Sep 18, 2016, 1:17 PM EDT
I have written in VB. You may convert it in C#
Sub Main()
Dim inputString As String = "Hello World"
Dim result = String.Join(" ", inputString.Split(" ").Select(Function(x) StrConv(String.Join("", x.Reverse().ToArray()), VbStrConv.ProperCase)))
Console.WriteLine(result)
Console.ReadLine()
End Sub
Somesh SrivastavaPosted Sep 18, 2016, 1:15 PM EDT
Static Void Main()
{
Console.WriteLine("type sentence");
String str = Console.ReadLine();
string revStr = " " ;
foreach(var word in str.Split(' '))
{
string temp = " ";
foreach(var ch in word.ToCharArray())
{
temp = ch temp;
}
revStr = revStr temp " ";
}
Console.writeLine(revStr);
Console.ReadLine();
}
Vinay KPosted Jul 6, 2016, 8:45 AM EDT
string inputString = "Hello World"; string result = string.Join(" ", inputString .Split(' ') .Select(x => new String(x.Reverse().ToArray()))); Console.WriteLine(result); Console.ReadLine();
Ashutosh PandeyPosted Jun 11, 2016, 3:03 AM EDT
string inputString = "Hello World"; string result = string.Join(" ", inputString .Split(' ') .Select(x => new String(x.Reverse().ToArray()))); Console.WriteLine(result); Console.ReadLine();
Ashutosh PandeyPosted Jun 11, 2016, 3:02 AM EDT
string inputString = "Hello World"; string result = string.Join(" ", inputString .Split(' ') .Select(x => new String(x.Reverse().ToArray()))); Console.WriteLine(result); Console.ReadLine();
Ashutosh PandeyPosted Jun 11, 2016, 3:02 AM EDT
1) Add the word by word in string of arrays,
2) Reverse the string value and then print the same.
Hellow world is reversed and printed as Olleh Dlrow
Bhuvanesh MohankumarPosted May 29, 2016, 7:23 AM EDT
string [] phrase= "hello world".Splt(' ');
foreach(var word in phrase)
{
string reversed = Array.Reverse(word.ToCharArray());
Console.Write("{0}{1} ",char.ToUpper(reversed[0]), reversed.Substring(1));
}
Rodrick EdwardsPosted May 27, 2016, 6:53 AM EDT
string inputString = "Hello World"; string result = string.Join(" ", inputString .Split(' ') .Select(x => new String(x.Reverse().ToArray()))); Console.WriteLine(result); Console.ReadLine();
vivekkumar kumarPosted May 25, 2016, 1:52 AM EDT
string inputString = "Hello World"; string result = string.Join(" ", inputString .Split(' ') .Select(x => new String(x.Reverse().ToArray()))); Console.WriteLine(result); Console.ReadLine();
vivekkumar kumarPosted May 25, 2016, 1:52 AM EDT
string inputString = "Hello World";
string result = string.Join(" ", inputString
.Split(' ')
.Select(x => new String(x.Reverse().ToArray())));
Console.WriteLine(result);
Console.ReadLine();
Sanjay KesarwaniPosted May 13, 2016, 10:20 AM EDT
string obj= "Hello World";
string[] _splitobj = obj.Split(' ');
for (int i = 0; i < _splitobj.Length;i++ )
{
for (int k = _splitobj[i].Length - 1; k >= 0;k-- )
{
Console.Write(_splitobj[i][k].ToString());
}
Console.Write(" ");
}
chandan yadavPosted May 12, 2016, 9:37 PM EDT
string obj= "Hello World";
string[] _splitobj = obj.Split(' ');
for (int i = 0; i < _splitobj.Length;i++ )
{
for (int k = _splitobj[i].Length - 1; k >= 0;k-- )
{
Console.Write(_splitobj[i][k].ToString());
}
Console.Write(" ");
}
chandan yadavPosted May 12, 2016, 9:35 PM EDT
string obj= "Hello World";
string[] _splitobj = obj.Split(' ');
for (int i = 0; i < _splitobj.Length;i++ )
{
for (int k = _splitobj[i].Length - 1; k >= 0;k-- )
{
Console.Write(_splitobj[i][k].ToString());
}
Console.Write(" ");
}
chandan yadavPosted May 12, 2016, 9:35 PM EDT
string obj= "Hello World";
string[] _splitobj = obj.Split(' ');
for (int i = 0; i < _splitobj.Length;i++ )
{
for (int k = _splitobj[i].Length - 1; k >= 0;k-- )
{
Console.Write(_splitobj[i][k].ToString());
}
Console.Write(" ");
}
chandan yadavPosted May 12, 2016, 9:35 PM EDT
string obj= "Hello World";
string[] _splitobj = obj.Split(' ');
for (int i = 0; i < _splitobj.Length;i++ )
{
for (int k = _splitobj[i].Length - 1; k >= 0;k-- )
{
Console.Write(_splitobj[i][k].ToString());
}
Console.Write(" ");
}
chandan yadavPosted May 12, 2016, 9:35 PM EDT
string obj= "Hello World";
string[] _splitobj = obj.Split(' ');
for (int i = 0; i < _splitobj.Length;i++ )
{
for (int k = _splitobj[i].Length - 1; k >= 0;k-- )
{
Console.Write(_splitobj[i][k].ToString());
}
Console.Write(" ");
}
chandan yadavPosted May 12, 2016, 9:35 PM EDT
class Program
{
static void Main(string[] args)
{
string str = "Hello World";
if (!string.IsNullOrEmpty(str))
{
Console.WriteLine("{0}", ReverseString(str));
Console.ReadLine();
}
else Console.WriteLine("String is empty");
}
private static string ReverseString(string str)
{
string revStr = "";
char sepearator = ' ';
string[] strArray = str.Split(sepearator);
for (int i = 0; i < strArray.Count(); i++)
{
if(i == 1)
{
revStr += " ";
}
for (int j = strArray[i].Length; j > 0; j--)
{
if (j == strArray[i].Length)
{
revStr += strArray[i].Substring(j - 1, 1).ToUpper();
}
else
{
revStr += strArray[i].Substring(j - 1, 1).ToLower();
}
}
}
return revStr;
}
}
Nikhil KhandelwalPosted May 9, 2016, 3:18 AM EDT
public StringBuilder ReverseString(string input)
{
StringBuilder reverseString = new StringBuilder();
foreach (string str in input.Split())
{
Char[] charArr = str.ToCharArray();
for (int i = charArr.Length-1; i >= 0; i--)
{
Console.WriteLine(charArr[i]);
}
reverseString.Append(" ");
}
return reverseString;
}
Rahul ChavanPosted Apr 6, 2016, 5:59 AM EDT
string str = "Print hello"
char[] arr = str.ToCharArray();
Array.Reverse(arr).ToString();
Sunil BabuPosted Apr 2, 2016, 3:22 AM EDT
string Str = "Hello World";
string Revstr = "";
for (int i = Str.Length - 1; i >= 0; i--)
{
Revstr += Str[i];
}
Console.WriteLine("Reverse String Is {0}", Revstr);
vipin kvPosted Mar 10, 2016, 3:31 AM EST
string obj= "Hello World"; for (int i = obj.Length - 1; i >= 0; i--) { Console.WriteLine(obj.[i]); }
Pankaj Kumar ChoudharyPosted Feb 9, 2016, 4:29 PM EST
class Program
{
static void Main(string[] args)
{
string LabOne = "Hello World";
string TempString = string.Empty;
string[] strArray = LabOne.Split(' ');
foreach (string item in strArray)
{
for (int i = item.Length - 1; i >= 0; i--)
{
TempString += item[i];
}
TempString += ' ';
}
//Now TempString='olleH dlroW'
//Converting into Title case
TextInfo textInfo = new CultureInfo("en-US", false).TextInfo;
TempString = textInfo.ToTitleCase(TempString);
Console.WriteLine(TempString);
Console.Read();
}
Aneez APosted Jan 22, 2016, 9:46 PM EST
public static string Reverse( string s )
{
char[] charArray = s.ToCharArray();
Array.Reverse( charArray );
return new string( charArray );
}
Shweta LodhaPosted Jan 21, 2016, 1:10 AM EST
really sorry for the above reply..
Please find below the solution
class Program
{
static void Main(string[] args)
{
string LabOne = "Hello World";
for (int i = LabOne.Length - 1; i >= 0; i--)
{
Console.WriteLine(LabOne.[i]);
}
}
}
Nishant MittalPosted Jan 19, 2016, 12:09 AM EST
I think you have to use the concept of localization and globalization in C#..I dont know which language is this Olleh Dlrow
Nishant MittalPosted Jan 19, 2016, 12:07 AM EST










