Hi,

Use the following code if you want to reverse the digits of a number using C Sharp/C #.

using System;

class MainClass {
  public static void Main() {

    int urNum;

    int urdigits;

    urNum = 123;

    Console.WriteLine("Given Number: " + urNum);

    Console.Write("Reversed Number: ");

    do {

      urdigits = urNum % 10;

      Console.Write(urdigits);

      urNum = urNum / 10;

    } while(urNum > 0);

    Console.WriteLine();

  }
}

Output :
Given Number: 123
Reversed Number: 321

🙂

 

Leave a Reply

Your email address will not be published. Required fields are marked *

 

 

 

Theme by HermesThemes

Copyright © 2018 CoderzHeaven. All Rights Reserved

Please wait...

Subscribe to our newsletter

Want to be notified when our article is published? Enter your email address and name below to be the first to know.