C# Program for Reverse Number - c# - c# tutorial - c# net




Related Tags: kurs c# , c# programmieren , tutorial c# visual studio , learn programming with c# , c# kurs online , the best way to learn c# , c# tutorial for complete beginners from scratch , tuto c# , manual c#

How to write Reverse Number Programs in C# ?

  • It can reverse the number entered by the user and then prints the reversed number on the screen
 c sharp program to reverse number
  • Let's see a simple C# example to reverse a given number.

Example1:

using System;  
  	public class ReverseExample  
   {  
     public static void Main(string[] args)  
      {  
       int  n, reverse=0, rem;           
       Console.Write("Enter a number: ");      
       n= int.Parse(Console.ReadLine());     
       while(n!=0)      
       {      
        rem=n%10;        
        reverse=reverse*10+rem;      
        n/=10;      
       }      
       Console.Write("Reversed Number: "+reverse);       
    }  }
click below button to copy the code. By - c# tutorial - team

C# examples - Output :

Enter a number: 234  
Reversed Number: 432

Example2:

/*
 * C# Program to Get a Number and Display the Number with its Reverse
 */
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
 
namespace Program
{
    class Program
    {
        static void Main(string[] args)
        {
            int num, reverse = 0;
            Console.WriteLine("Enter a Number : ");
            num = int.Parse(Console.ReadLine());
            while (num != 0)
            {
                reverse = reverse * 10;
                reverse = reverse + num % 10;
                num = num / 10;
            }
            Console.WriteLine("Reverse of Entered Number is: "+reverse);
            Console.ReadLine();
 
        }
    }
}
click below button to copy the code. By - c# tutorial - team
Related Tags: kurs c# , c# programmieren , tutorial c# visual studio , learn programming with c# , c# kurs online , the best way to learn c# , c# tutorial for complete beginners from scratch , tuto c# , manual c#

output:

Enter a Number: 123
Reverse of Entered Number: 321


Related Searches to C# Program for Reverse Number

Adblocker detected! Please consider reading this notice.

We've detected that you are using AdBlock Plus or some other adblocking software which is preventing the page from fully loading.

We don't have any banner, Flash, animation, obnoxious sound, or popup ad. We do not implement these annoying types of ads!

We need money to operate the site, and almost all of it comes from our online advertising.

Please add wikitechy.com to your ad blocking whitelist or disable your adblocking software.

×