16 Program to print 1 to 500 Armstrong numbers Using For Loop in VB.NET

Code:

Module Module1

    Sub Main()

        Dim num, temp, r, s, t As Integer

        Console.WriteLine(" Armstrong Number Between 1 to 500: ")

        For num = 1 To 500

            temp = num
            s = 0

            For t = 0 To num
                r = temp Mod 10
                s = (r * r * r) + s
                temp = temp \ 10
            Next

            If num = s Then
                Console.WriteLine(num)
            End If

        Next

        Console.ReadKey()

    End Sub

End Module







Output:  

Previous
Next Post »

1 Comments:

Click here for Comments
Unknown
admin
August 22, 2024 at 6:08 PM ×

Very good programming technique for remember

Thank You Unknown For Comment.
Reply
avatar