12 Program to check Armstrong Number in VB.NET

Code:

Module Module1

    Sub Main()

        Dim num, temp, r, s As Integer

        Console.WriteLine(" Enter any number ")
        num = Console.ReadLine()

        temp = num
        s = 0

        While temp > 0
            r = temp Mod 10
            s = (r * r * r) + s
            temp = temp \ 10
        End While

        If num = s Then
            Console.WriteLine(" Armstrong Number ")
        Else
            Console.WriteLine(" Not  Armstrong Number ")
        End If

        Console.ReadKey()

    End Sub

End Module


Output:  


Previous
Next Post »