To input any five numbers into an array and find the sum of even numbers only. (Qbasic Code)

To input any five numbers into an array and find the sum of even numbers only. (Qbasic Code)
  • CLS
    s = 0
    FOR i = 1 TO 5
        INPUT "Enter the number"; n(i)
        a(i) = n(i) MOD 2
        IF a(i) = 0 THEN
            s = s + n(i)
        END IF
    NEXT i
    PRINT "The sum of the numbers"; s
    END

Share :

Twitter
Back To Top

facebook main

counter

Powered by Blogger.