Search This Blog

This website completely moved to new domain. For latest content, visit www.programmingposts.com

C# Program to Print Reverse Of a Given Number



C# program to find reverse of a given number

using System;

namespace ReverseNumber
{
    class Program
    {
        static void Main(string[] args)
        {

            int num, rem, sum = 0, rev;
            Console.WriteLine("\n /** To Find Reverse Of a Number **/");
            Console.Write("\n Enter a number: ");
            num=Convert.ToInt32(Console.ReadLine());
            while (Convert.ToBoolean(num))
            {
                rem = num % 10;  //for getting remainder by dividing with 10
                num = num / 10; //for getting quotient by dividing with 10
                sum = sum * 10 + rem;
            }
            rev = sum;
            Console.WriteLine("\n The Reversed Number is: {0} \n\n", rev);
            Console.ReadLine();
        }
    }
}

Output:

For C Program : C Program To Find The Reverse Of a Given Number


8 comments:

  1. Replies
    1. This comment has been removed by the author.

      Delete
  2. how does it works please explain
    rem = num % 10;
    num = num / 10;
    sum = sum * 10 + rem;
    this logic

    ReplyDelete
  3. New and used slot machines - Pragmatic Play - AprCasino
    NEW AND NEW 1xbet 먹튀 SLOT gri-go.com MACHINES kadangpintar WITH A aprcasino HIGH RTP! For the ultimate high-quality gaming experience, Pragmatic Play offers all of 출장안마 the

    ReplyDelete