To display Armstrong numbers from 1 to 500 (Qbasic Code)

To display Armstrong numbers from 1 to 500 (Qbasic Code)
  • CLS
    FOR i = 1 TO 500
        a = 0
        b = i
        WHILE b <> 0
            r = b MOD 10
            a = a + r ^ 3
            b = b \ 10
        WEND
        IF a = i THEN PRINT i
    NEXT i
    END

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.