January 31, 2020

Qbasic Program to check the greatest and smallest number along with their differecnce among ten numbers [Using Array]

            CLS
            DIM a(10) AS DOUBLE
            DIM g AS DOUBLE
            DIM s AS DOUBLE
            DIM i AS INTEGER
            DIM c AS STRING
         
            PRINT "Enter the  1 st": INPUT "number: ", a(1)
            g = a(1): s = a(1)
            CLS
            FOR i = 2 TO 10
                    SELECT CASE i
                    CASE IS = 2
                    c = "nd"
                    CASE IS = 3
                    c = "rd"
                    CASE ELSE
                    c = "th"
                    END SELECT
           
            PRINT "Enter the "; i; c: INPUT "number: ", a(i)
            CLS
          
            IF a(i) > g THEN g = a(i)
            IF a(i) < s THEN s = a(i)
            NEXT i
        
            PRINT
            PRINT
            PRINT
            PRINT "The greatest number is : ", g
            PRINT "The smallest number is : ", s
            PRINT "Difference between is  : ", g; "-"; s; "="; g - s
            END

No comments:

Post a Comment

Note: Only a member of this blog may post a comment.