Advertisement
sylviapsh

Reverse String

Jan 28th, 2013
104
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C# 0.43 KB | None | 0 0
  1. using System;
  2.  
  3. class ReverseStringLetters
  4. {
  5.   //Write a program that reads a string, reverses it and prints the result at the console.
  6.   //Example: "sample" -> "elpmas".
  7.  
  8.   static void Main()
  9.   {
  10.     Console.WriteLine("Enter a string to reverse: ");
  11.     string input = Console.ReadLine();
  12.    
  13.     for (int i = input.Length - 1; i >= 0; i--)
  14.     {
  15.       Console.Write(input[i]);
  16.     }
  17.     Console.WriteLine();
  18.   }
  19. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement