December 2, 2020

Qbasic program to print 54321, 4321, 321, 21, 1

CLS

FOR i = 5 TO 1 STEP -1

FOR j = i TO 1 STEP -1

PRINT j;

NEXT j

PRINT

NEXT i

END

Output: 

5 4 3 2 1

4 3 2 1

3 2 1

2 1

1

February 6, 2020

Qbasic Program to sort the random string data in ascending order

DIM a(10) AS STRING
DIM b AS STRING
DIM i AS INTEGER
DIM x AS INTEGER


CLS
FOR i = 1 TO 10
INPUT "enter the string data : ", a(i)
a(i)=UCASE$(a(i))
NEXT i


FOR x = 1 TO 10
        FOR i = 1 TO 10 - j
        IF a(i) > a(i + 1) THEN b = a(i): a(i) = a(i + 1): a(i + 1) = b
        NEXT i
NEXT x


PRINT "The sorted string data in ascending order:"
FOR i = 1 TO 10
PRINT a(i)
NEXT i

END

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

January 19, 2020

WAP to display the series: 2,2,4,6,10,......., up to 10th term

(using DO - LOOP)
CLS
a = 2 : b = 2 : I = 1
PRINT a; b;
DO WHILE I <= 8
c = a+ b
PRINT c;
a = b
b = c
I = I + 1
LOOP
END

(using FOR - NEXT)
CLS
a = 2 : b = 2
PRINT a; b;
FOR I = 1 TO 8
c = a + b
PRINT c;
a = b
b = c
NEXT I
END

January 7, 2020

WAP to display 2,4,6,8,......,10th term

(using DO - LOOP)
CLS
I = 2
DO WHILE I < = 20
PRINT I;
I = I + 2
LOOP
END

WAP to display 100,90,80,.......,10

(using FOR - NEXT)
CLS
FOR I = 100 TO 10 STEP -10
PRINT I;
NEXT I
END

(using WHILE - WEND)
CLS
I = 100
WHILE I >= 10
PRINT I;
I = I - 10
WEND
END

WAP to print the series: 5,10,15,........50

(using FOR - NEXT)
CLS
FOR I = 5 TO 50 STEP 5
PRINT I;
NEXT I
END

(using WHILE - WEND)
CLS
I = 5
WHILE I <= 50
PRINT I;
I = I + 5
WEND
END