C# Sharp Exercises: Print a string in reverse order
C# Sharp For Loop: Exercise-57 with Solution
Write a program in C# Sharp to print a string in reverse order.
Sample Solution:-
C# Sharp Code:
using System;
public class Exercise57
{
public static void Main()
{
string str, str1 = "";
int i,l;
Console.Write("\n\n");
Console.Write("Print a string in reverse order:\n");
Console.Write("----------------------------------");
Console.Write("\n\n");
Console.Write("Input A String : ");
str = Console.ReadLine();
l = str.Length-1;
for (i=l;i>=0;i--)
{
str1 = str1 + str[i];
}
Console.WriteLine("The string in Reverse Order Is : {0}", str1);
Console.Write("\n");
}
}
Sample Output:
Print a string in reverse order: ---------------------------------- Input A String : W3RESOURCE The string in Reverse Order Is : ECRUOSER3W
Flowchart:
C# Sharp Code Editor:
Contribute your code and comments through Disqus.
Previous: Write a program in C# Sharp to Check Whether a Number can be Express as Sum of Two Prime Numbers.
Next: Write a C#Sharp program to display alphabet pattern like 'A' with an asterisk.
What is the difficulty level of this exercise?
Test your Programming skills with w3resource's quiz.
- New Content published on w3resource:
- HTML-CSS Practical: Exercises, Practice, Solution
- Java Regular Expression: Exercises, Practice, Solution
- Scala Programming Exercises, Practice, Solution
- Python Itertools exercises
- Python Numpy exercises
- Python GeoPy Package exercises
- Python Pandas exercises
- Python nltk exercises
- Python BeautifulSoup exercises
- Form Template
- Composer - PHP Package Manager
- PHPUnit - PHP Testing
- Laravel - PHP Framework
- Angular - JavaScript Framework
- Vue - JavaScript Framework
- Jest - JavaScript Testing Framework