Business Logic for the given condition.

Posted by Gokul under C# on 6/23/2011 | Points: 10 | Views : 938 | Status : [Member] | Replies : 6
Dear Friends,
I want the output to be like shown below:

5 4 3 2 1
1 2 3 4
3 2 1
1 2
1

Input="welcome"
Output: w \$ e\$ l \$ c\$ o \$ m \$ e

Thanks and Regards,
GokulNath Nithy.

Responses

Posted by: Jpchoudhari on: 6/23/2011 [Member] Starter | Points: 25
 0 static void Main(string[] args) { Console.WriteLine("Enter no "); int cnt = int.Parse(Console.ReadLine()); int iCnt = cnt; int iDisplay = cnt; for (int i = 1; i <= cnt; i++) { if (i % 2 != 0) iDisplay = iCnt; else iDisplay = 1; for (int j = iCnt; j > 0; j--) { if (i % 2 != 0) { Console.Write(iDisplay + " "); iDisplay--; } else { Console.Write(iDisplay + " "); iDisplay++; } } iCnt--; Console.WriteLine(); } Console.ReadLine(); } static void Main(string[] args) { Console.WriteLine("Enter string : "); string strLabel= Console.ReadLine(); for (int i = 0; i < strLabel.Length; i++) { Console.Write(strLabel[i]); if (i < strLabel.Length-1) Console.Write(" \$ "); } Console.ReadLine(); } Thanks and Regards, Jaydeep ChoudhariKind Regards, JayGokul, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Lakn2 on: 6/27/2011 [Member] Starter | Points: 25
 0 second code is not giving output as per requirement actual o/p w \$ e \$ ... but your code gives welcome \$ welcome \$ ..Thanks&Regards LakshmiNarayana Nalluri.Gokul, if this helps please login to Mark As Answer. | Alert Moderator
Posted by: Lakn2 on: 6/27/2011 [Member] Starter | Points: 25