C Sharp


Program to Print String in Reverse tutorials
|
Example: C# program to enter string with spaces and print it in reverse order |
![]() |
// Program name : test069.cs// C# program to enter string with spaces and print it in reverse orderusing System;class Program{static void Main(string[] args){string Str, Revstr = "";Console.Write("Enter String : ");Str = Console.ReadLine();for (int i = Str.Length - 1; i >= 0; i--){Revstr = Revstr + Str[i];}Console.WriteLine("{0}", Revstr);Console.ReadLine();}} |
Output |
Enter String : cbtSammaStbcEnter String : sam computerssretupmoc mas |