Display the digits of an integer in reverse order : While : Language Basics C# Source Code


Custom Search

C# Source Code » Language Basics » While »

 

Display the digits of an integer in reverse order









    

/*
C#: The Complete Reference 
by Herbert Schildt 

Publisher: Osborne/McGraw-Hill (March 8, 2002)
ISBN: 0072134852
*/
// Display the digits of an integer in reverse order. 
 
using System; 
 
public class DoWhileDemo {   
  public static void Main() { 
    int num; 
    int nextdigit; 
 
    num = 198; 
 
    Console.WriteLine("Number: " + num); 
 
    Console.Write("Number in reverse order: "); 
 
    do { 
      nextdigit = num % 10; 
      Console.Write(nextdigit); 
      num = num / 10; 
    } while(num > 0); 
 
    Console.WriteLine(); 
  }   
}

           
       
    
   
  
   







HTML code for linking to this page:

Follow Navioo On Twitter

C# Source Code

 Navioo Language Basics
» While