QBASIC PROGRAMMING SLC/SEE
To input any number and display whether input number is positive negative or neutral
CLS
INPUT " enter any number"; n
r = SGN(n)
IF r = 1 THEN
PRINT "positive"
ELSEIF r = -1 THEN
PRINT "egative"
ELSE
PRINT "neutral"
END IF
END
To check whether input number is perfectly divisible by 3 and 5
CLS
INPUT "enter any number"; n
r = n MOD 3
r1 = n MOD 5
IF r = 0 AND r1 = 0 THEN
PRINT "perfectly divisible"
ELSE
PRINT "not perfectly divisible"
END IF
END
To display the middle number among given three numbers
CLS
INPUT "enter any number"; a, b, c
IF a > b AND a < c OR a < b AND a > c THEN m = a
IF b > a AND b < c OR b < a AND b > c THEN m = b
IF c > a AND c < b OR c < a AND c > b THEN m = c
PRINT m
END
To display first 10 number with its square and cube
CLS
PRINT "number", "square", "cube"
FOR x = 1 TO 10
PRINT x, x ^ 2, x ^ 3
NEXT
END
To input which no table and how many times. to display the multiplication table
CLS
INPUT "enter which no table"; n
INPUT "enter how many times"; t
FOR x = 1 TO t
PRINT n; "X"; "="; x * n
NEXT x
END
To display the series of number 525,500,475....upto 15^th term
CLS
a = 525
x = 1
WHILE x <= 15
PRINT a;
a = a - 25
x = x + 1
WEND
END
WAP to display the factorial of input number
CLS
INPUT "enter a number to find a factorial"; n
c = 1
f = 1
DO
f = f * c
c = c + 1
LOOP WHILE c <= n
PRINT "factorial of"; n; "=+;f"
END
WAP to display the Fibonacci series 1 1 2 3 5 8 ............... 12 ^th term
CLS
a = 1
b = 1
x = 1
PRINT a; b;
DO WHILE x <= 10
c = a + b
PRINT c;
a = b
b = c
x = x + 1
LOOP
END
To display the multiplication table of 2 to 9 up to 10^th term
CLS
FOR x = 2 TO 9
FOR y = 1 TO 10
PRINT x; "x"; y; "="; x * y
NEXT y
PRINT "press any key to continue"
b$ = INPUT$(1)
NEXT x
END
WAP to display the square root of first 10 natural number
CLS
PRINT "number", "square root"
FOR x = 1 TO 10
PRINT x, SQR(x)
NEXT
END
WAP to display whether input number is perfect square or not
CLS
INPUT "enter any number"; n
r = SQR(n)
s = INT(r)
IF s = r THEN
PRINT "perfect square"
ELSE
PRINT "not perfect square"
END IF
END
To input any string and display it in reverse order
CLS
INPUT "enter any string"; n$
FOR x = LEN(n$) TO 1 STEP -1
PRINT MID$(n$, x, 1);
NEXT x
END
Comments
Post a Comment
Please do not enter any spam link in the comment box