Display the digits of an integer in reverse order with do while loop : Do While « Statement « C# / CSharp Tutorial






using System; 
 
class MainClass {   
  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(); 
  }   
}
Number: 198
Number in reverse order: 891








4.6.Do While
4.6.1.Do while loop
4.6.2.Display the digits of an integer in reverse order with do while loop
4.6.3.Using break to exit a do-while loop
4.6.4.Use the do while statement to implement Newton's method for finding the square root of a number
4.6.5.Do / while loop with a console read