Q:

Write a program in C# Sharp to display the number in reverse order

0

Write a program in C# Sharp to display the number in reverse order

Sample Output:

Display the number in reverse order:                                                                        
--------------------------------------                                                                      
Input a number: 25                                                                                          
The number in reverse order is : 52

All Answers

need an explanation for this answer? contact us directly to get an explanation for this answer

using System;  
public class Exercise37 
{  
    public static void Main()
{
    int num,r,sum=0,t;
	
	Console.Write("\n\n");
    Console.Write("Display the number in reverse order:\n");
    Console.Write("--------------------------------------");
    Console.Write("\n\n");  	
	

    Console.Write("Input a number: ");
    num = Convert.ToInt32(Console.ReadLine()); 	

    for(t=num;t!=0;t=t/10)
	{
         r=t % 10;
         sum=sum*10+r;
    }
Console.Write("The number in reverse order is : {0} \n",sum);
  }
}

need an explanation for this answer? contact us directly to get an explanation for this answer

total answers (1)

Similar questions


need a help?


find thousands of online teachers now