Qbasic Program to convert decimal to hexadecimal  

Posted by Mahibabu

REM Program to convert decimal to hexadecimal
CLS
INPUT "Enter decimal number"; d
WHILE d <> 0
r = d MOD 16
IF r = 10 THEN
r$ = "A"
ELSEIF r = 11 THEN
r$ = "B"
ELSEIF r = 12 THEN
r$ = "C"
ELSEIF r = 13 THEN
r$ = "D"
ELSEIF r = 14 THEN
r$ = "E"
ELSEIF r = 15 THEN
r$ = "F"
ELSE
r$ = STR$(r)
END IF
h$ = r$ + h$
d = d \ 16
WEND
PRINT "Hexadecimal is"; h$
END

Qbasic Program to print the short form of the name  

Posted by Mahibabu

REM Program to print the short form of the name
CLS
INPUT "Enter your first, middle and last name "; n$
b$ = UCASE$(MID$(n$, 1, 1))
w$ = w$ + b$ + "."
a$ = a$ + b$
FOR i = 2 TO LEN(n$)
b$ = UCASE$(MID$(n$, i, 1))
IF RIGHT$(a$, 1) = " " THEN w$ = w$ + b$ + "."
a$ = a$ + b$
NEXT
PRINT w$
END

Qbasic Program to Print longest and the shortest word among ten different words  

Posted by Mahibabu

REM Program to print longest and shortest among ten words
CLS
INPUT "Enter first word "; a$
l$ = a$
s$ = a$
l = LEN(l$)
s = LEN(s$)
FOR i = 2 TO 10
INPUT "Enter next word"; b$
b = LEN(b$)
IF b > l THEN
l$ = b$
l = b
ELSEIF b < s THEN
s$ = b$
s = b
END IF
NEXT i
PRINT "The longest word is "; l$
PRINT "The shortest word is "; s$
END

Qbasic Program to print the cube root of a given number  

Posted by Mahibabu

REM Program to print the cube root of a given number
CLS
INPUT "Enter any number"; n
c = n ^ 1 \ 3
PRINT "Cube root is"; c
END

Qbasic program to print the smallest among ten different numbers  

Posted by Mahibabu

REM Program to print the smallest among ten different numbers
CLS
INPUT "Enter first number"; n
FOR i = 2 TO 10
INPUT "Enter next number"; s
IF s < n THEN
n = s
END IF
NEXT i
PRINT "The smallest number is"; n
END

Qbasic Program to check whether the given number is palindrome or not  

Posted by Mahibabu

REM Program to check whether the given number is palindrome or not.
CLS
INPUT "Enter any digit"; n
a = n
WHILE n <> 0
r = n MOD 10
s = s * 10 + r
n = n \ 10
WEND
IF a = s THEN
PRINT a; " is Palindrome"
ELSE
PRINT a; " is not palindrome "
END IF
END

Qbasic Program to reverse the given digits  

Posted by Mahibabu

REM Program to reverse the digits
CLS
INPUT "Enter any digit"; n
WHILE n <> 0
r = n MOD 10
s = s * 10 + r
n = n \ 10
WEND
PRINT "Reversed digits is "; s
END

Contributors

My photo
I am Mahesh Bhandari from Kathmandu, Nepal

Check Nepal's Time