**Qbasic program to check entered letter is capital or small(uppercase or lowercase)**

REM PROGRAM TO CHECK
ENTERED NUMBER IS UPPERCASE OR LOWERCASE

CLS

INPUT “Enter a letter”;A$

U$=UCASE$(A$)

IF U$=A$ THEN

PRINT “It is capital letter”

ELSE

PRINT “It is small letter”

ENDIF

END

CLS

INPUT “Enter a letter”;A$

U$=UCASE$(A$)

IF U$=A$ THEN

PRINT “It is capital letter”

ELSE

PRINT “It is small letter”

ENDIF

END

USING DECLARE FUNCTION
PROCEDURE

DECLARE FUNCTION UC$
(A$)

CLS

INPUT “Enter a letter”; A$

PRINT UC$(A$)

END

CLS

INPUT “Enter a letter”; A$

PRINT UC$(A$)

END

FUNCTION UC$ (A$)

CH$ = UCASE$(A$)

IF A$ = CH$ THEN

UC$ = “It is capital letter”

ELSE

UC$ = “It is small letter”

END IF

END FUNCTION

CH$ = UCASE$(A$)

IF A$ = CH$ THEN

UC$ = “It is capital letter”

ELSE

UC$ = “It is small letter”

END IF

END FUNCTION

USING DECLARE SUB
PROCEDURE

DECLARE SUB UC(A$)

CLS

INPUT “Enter a letter”; A$

CALL UC(A$)

END

CLS

INPUT “Enter a letter”; A$

CALL UC(A$)

END

SUB UC(A$)

CH$ = UCASE$(A$)

IF A$ = CH$ THEN

PRINT “It is capital letter”

ELSE

PRINT “It is small letter”

END IF

END SUB

CH$ = UCASE$(A$)

IF A$ = CH$ THEN

PRINT “It is capital letter”

ELSE

PRINT “It is small letter”

END IF

END SUB

CLS

INPUT “ENTER A NUMBER”; N

S = N

WHILE N <> 0

A = N MOD 10

R = R * 10 + A

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

INPUT “ENTER A NUMBER”; N

S = N

WHILE N <> 0

A = N MOD 10

R = R * 10 + A

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

**Using Declare Sub Procedure**

DECLARE SUB A (N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A (N)

S = N

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “IT IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A (N)

S = N

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “IT IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

CLS

INPUT “ENTER A STRING”; S$

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

IF S$ = REV$ THEN

PRINT “THE GIVEN STRING IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

INPUT “ENTER A STRING”; S$

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

IF S$ = REV$ THEN

PRINT “THE GIVEN STRING IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

**Using declare sub**

DECLARE SUB A(S$)

CLS

INPUT “ENTER A STRING”; S$

CALL A(S$)

END

SUB A(S$)

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

IF S$ = REV$ THEN

PRINT “THE GIVEN STRING IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

CLS

INPUT “ENTER A STRING”; S$

CALL A(S$)

END

SUB A(S$)

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

IF S$ = REV$ THEN

PRINT “THE GIVEN STRING IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

CLS

INPUT “ENTER A NUMBER”; N

S = N

WHILE N <> 0

A = N MOD 10

R = R + A ^ 3

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

INPUT “ENTER A NUMBER”; N

S = N

WHILE N <> 0

A = N MOD 10

R = R + A ^ 3

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

**Using declare sub procedure**

DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

S=N

WHILE N <> 0

B = N MOD 10

R = R + B ^ 3

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

END SUB

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

S=N

WHILE N <> 0

B = N MOD 10

R = R + B ^ 3

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

END SUB

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 10

R = R * 10 + A

N = FIX(N / 10)

WEND

PRINT R

END

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 10

R = R * 10 + A

N = FIX(N / 10)

WEND

PRINT R

END

*Using declare sub procedure*
DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

PRINT R

END SUB

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

PRINT R

END SUB

*Using declare function procedure*
DECLARE FUNCTION A(N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT A(N)

END

FUNCTION A(N)

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

A=R

END FUNCTION

CLS

INPUT “ENTER A NUMBER”; N

PRINT A(N)

END

FUNCTION A(N)

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

A=R

END FUNCTION

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER INTO HEXADECIMAL

CLS

INPUT “ENTER A DECIMAL VALUE”; N

WHILE N <> 0

K = N MOD 16

IF K = 10 THEN

B$ = “A”

ELSEIF K = 11 THEN

B$ = “B”

ELSEIF K = 12 THEN

B$ = “C”

ELSEIF K = 13 THEN

B$ = “D”

ELSEIF K = 14 THEN

B$ = “E”

ELSEIF K = 15 THEN

B$ = “F”

ELSE

B$ = STR$(K)

END IF

H$ = B$ + H$

N = FIX(N / 16)

WEND

PRINT “HEXADECIMAL VALUE IS “; H$

END

CLS

INPUT “ENTER A DECIMAL VALUE”; N

WHILE N <> 0

K = N MOD 16

IF K = 10 THEN

B$ = “A”

ELSEIF K = 11 THEN

B$ = “B”

ELSEIF K = 12 THEN

B$ = “C”

ELSEIF K = 13 THEN

B$ = “D”

ELSEIF K = 14 THEN

B$ = “E”

ELSEIF K = 15 THEN

B$ = “F”

ELSE

B$ = STR$(K)

END IF

H$ = B$ + H$

N = FIX(N / 16)

WEND

PRINT “HEXADECIMAL VALUE IS “; H$

END

**Using declare function procedure**

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER INTO HEXADECIMAL

DECLARE FUNCTION Z$ (N)

CLS

INPUT “ENTER A DECIMAL VALUE”; N

PRINT “HEXADECIMAL VALUE IS “; Z$(N)

END

DECLARE FUNCTION Z$ (N)

CLS

INPUT “ENTER A DECIMAL VALUE”; N

PRINT “HEXADECIMAL VALUE IS “; Z$(N)

END

FUNCTION Z$ (N)

WHILE N <> 0

K = N MOD 16

IF K = 10 THEN

B$ = “A”

ELSEIF K = 11 THEN

B$ = “B”

ELSEIF K = 12 THEN

B$ = “C”

ELSEIF K = 13 THEN

B$ = “D”

ELSEIF K = 14 THEN

B$ = “E”

ELSEIF K = 15 THEN

B$ = “F”

ELSE

B$ = STR$(K)

END IF

H$ = B$ + H$

N = FIX(N / 16)

WEND

Z$ = H$

END FUNCTION

WHILE N <> 0

K = N MOD 16

IF K = 10 THEN

B$ = “A”

ELSEIF K = 11 THEN

B$ = “B”

ELSEIF K = 12 THEN

B$ = “C”

ELSEIF K = 13 THEN

B$ = “D”

ELSEIF K = 14 THEN

B$ = “E”

ELSEIF K = 15 THEN

B$ = “F”

ELSE

B$ = STR$(K)

END IF

H$ = B$ + H$

N = FIX(N / 16)

WEND

Z$ = H$

END FUNCTION

**Using declare sub procedure**

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER INTO HEXADECIMAL

DECLARE SUB Z (N)

CLS

INPUT “ENTER A DECIMAL VALUE”; N

CALL Z(N)

END

DECLARE SUB Z (N)

CLS

INPUT “ENTER A DECIMAL VALUE”; N

CALL Z(N)

END

SUB Z (N)

WHILE N <> 0

K = N MOD 16

IF K = 10 THEN

B$ = “A”

ELSEIF K = 11 THEN

B$ = “B”

ELSEIF K = 12 THEN

B$ = “C”

ELSEIF K = 13 THEN

B$ = “D”

ELSEIF K = 14 THEN

B$ = “E”

ELSEIF K = 15 THEN

B$ = “F”

ELSE

B$ = STR$(K)

END IF

H$ = B$ + H$

N = FIX(N / 16)

WEND

PRINT “HEXADECIMAL VALUE IS “; H$

END SUB

WHILE N <> 0

K = N MOD 16

IF K = 10 THEN

B$ = “A”

ELSEIF K = 11 THEN

B$ = “B”

ELSEIF K = 12 THEN

B$ = “C”

ELSEIF K = 13 THEN

B$ = “D”

ELSEIF K = 14 THEN

B$ = “E”

ELSEIF K = 15 THEN

B$ = “F”

ELSE

B$ = STR$(K)

END IF

H$ = B$ + H$

N = FIX(N / 16)

WEND

PRINT “HEXADECIMAL VALUE IS “; H$

END SUB

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER TO Octal

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

PRINT “QUAINARY EQUIVALENT IS”; C$

END

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

PRINT “QUAINARY EQUIVALENT IS”; C$

END

**Using declare sub procedure**

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER TO Octal

DECLARE SUB O(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL O(N)

END

SUB O(N)

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

PRINT “QUAINARY EQUIVALENT IS”; C$

END SUB

DECLARE SUB O(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL O(N)

END

SUB O(N)

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

PRINT “QUAINARY EQUIVALENT IS”; C$

END SUB

**Using declare function procedure**

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER TO Octal

DECLARE FUNCTION O$(N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “QUAINARY EQUIVALENT IS”; O$(N)

END

FUNCTION O$(N)

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

O$=C$

END FUNCTION

DECLARE FUNCTION O$(N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “QUAINARY EQUIVALENT IS”; O$(N)

END

FUNCTION O$(N)

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

O$=C$

END FUNCTION

CLS

INPUT “ENTER A STRING”; S$

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END

INPUT “ENTER A STRING”; S$

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END

**Using declare sub procedure**

DECLARE SUB A(S$)

CLS

INPUT “ENTER A STRING”; S$

CALL A(S$)

END

SUB A(S$)

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END SUB

CLS

INPUT “ENTER A STRING”; S$

CALL A(S$)

END

SUB A(S$)

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END SUB

**Using declare function procedure**

DECLARE FUNCTION A$
(S$)

CLS

INPUT “ENTER A STRING”; S$

PRINT A$(S$)

END

FUNCTION A$ (S$)

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

A$ = REV$

END FUNCTION

CLS

INPUT “ENTER A STRING”; S$

PRINT A$(S$)

END

FUNCTION A$ (S$)

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

A$ = REV$

END FUNCTION

‘THIS PROGRAM CONVERTS
HEXADECIMAL TO DECIMAL

CLS

INPUT “ENTER HEXADECIMAL VALUE”;B$

FOR I=LEN(B$) TO 1 STEP -1

A$=MID$(B$,I,1)

C=VAL(A$)

IF A$=”A” THEN C=10

IF A$=”B” THEN C=11

IF A$=”C” THEN C=12

IF A$=”D” THEN C=13

IF A$=”E” THEN C=14

IF A$=”F” THEN C=15

H=H+C*16^P

P=P+1

NEXT I

PRINT “DECIMAL VALUE IS”;H

END

CLS

INPUT “ENTER HEXADECIMAL VALUE”;B$

FOR I=LEN(B$) TO 1 STEP -1

A$=MID$(B$,I,1)

C=VAL(A$)

IF A$=”A” THEN C=10

IF A$=”B” THEN C=11

IF A$=”C” THEN C=12

IF A$=”D” THEN C=13

IF A$=”E” THEN C=14

IF A$=”F” THEN C=15

H=H+C*16^P

P=P+1

NEXT I

PRINT “DECIMAL VALUE IS”;H

END

**Using declare function procedure**

‘THIS PROGRAM CONVERTS
HEXADECIMAL TO DECIMAL

DECLARE FUNCTION Z(B$)

CLS

INPUT “ENTER HEXADECIMAL VALUE”;B$

PRINT “DECIMAL VALUE IS”;Z(B$)

END

FUNCTION Z(B$)

FOR I=LEN(B$) TO 1 STEP -1

A$=MID$(B$,I,1)

C=VAL(A$)

IF A$=”A” THEN C=10

IF A$=”B” THEN C=11

IF A$=”C” THEN C=12

IF A$=”D” THEN C=13

IF A$=”E” THEN C=14

IF A$=”F” THEN C=15

H=H+C*16^P

P=P+1

NEXT I

Z=H

END FUNCTION

DECLARE FUNCTION Z(B$)

CLS

INPUT “ENTER HEXADECIMAL VALUE”;B$

PRINT “DECIMAL VALUE IS”;Z(B$)

END

FUNCTION Z(B$)

FOR I=LEN(B$) TO 1 STEP -1

A$=MID$(B$,I,1)

C=VAL(A$)

IF A$=”A” THEN C=10

IF A$=”B” THEN C=11

IF A$=”C” THEN C=12

IF A$=”D” THEN C=13

IF A$=”E” THEN C=14

IF A$=”F” THEN C=15

H=H+C*16^P

P=P+1

NEXT I

Z=H

END FUNCTION

**Using declare sub procedure**

‘THIS PROGRAM CONVERTS
HEXADECIMAL TO DECIMAL

DECLARE SUB Z(B$)

CLS

INPUT “ENTER HEXADECIMAL VALUE”;B$

CALL Z(B$)

END

SUB Z(B$)

FOR I=LEN(B$) TO 1 STEP -1

A$=MID$(B$,I,1)

C=VAL(A$)

IF A$=”A” THEN C=10

IF A$=”B” THEN C=11

IF A$=”C” THEN C=12

IF A$=”D” THEN C=13

IF A$=”E” THEN C=14

IF A$=”F” THEN C=15

H=H+C*16^P

P=P+1

NEXT I

PRINT “DECIMAL VALUE IS”;H

END SUB

DECLARE SUB Z(B$)

CLS

INPUT “ENTER HEXADECIMAL VALUE”;B$

CALL Z(B$)

END

SUB Z(B$)

FOR I=LEN(B$) TO 1 STEP -1

A$=MID$(B$,I,1)

C=VAL(A$)

IF A$=”A” THEN C=10

IF A$=”B” THEN C=11

IF A$=”C” THEN C=12

IF A$=”D” THEN C=13

IF A$=”E” THEN C=14

IF A$=”F” THEN C=15

H=H+C*16^P

P=P+1

NEXT I

PRINT “DECIMAL VALUE IS”;H

END SUB

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER TO BINARY

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 2

B$ = STR$(A)

N = FIX(N / 2)

C$ = B$ + C$

WEND

PRINT “BINARY EQUIVALENT IS”; C$

END

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 2

B$ = STR$(A)

N = FIX(N / 2)

C$ = B$ + C$

WEND

PRINT “BINARY EQUIVALENT IS”; C$

END

**Using declare sub procedure**

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER TO BINARY

DECLARE SUB A (N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

DECLARE SUB A (N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A (N)

WHILE N <> 0

E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

PRINT “BINARY EQUIVALENT IS”; C$

END SUB

WHILE N <> 0

E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

PRINT “BINARY EQUIVALENT IS”; C$

END SUB

**Using declare function procedure**

‘THIS PROGRAM CONVERTS
DECIMAL NUMBER TO BINARY

DECLARE FUNCTION A$ (N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “BINARY EQUIVALENT IS”; A$(N)

END

DECLARE FUNCTION A$ (N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “BINARY EQUIVALENT IS”; A$(N)

END

FUNCTION A$ (N)

WHILE N <> 0

E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

A$=C$

END FUNCTION

WHILE N <> 0

E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

A$=C$

END FUNCTION

‘THIS PROGRAM CONVERTS
BINARY NUMBER TO DECIMAL

CLS

INPUT “ENTER A BINARY NUMBER”; B$

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

M = M + C * 2 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS “; M

END

CLS

INPUT “ENTER A BINARY NUMBER”; B$

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

M = M + C * 2 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS “; M

END

**Using declare sub procedure**

‘THIS PROGRAM CONVERTS
BINARY NUMBER TO DECIMAL

DECLARE SUB Z(B$)

CLS

INPUT “ENTER A BINARY NUMBER”; B$

CALL Z(B$)

END

SUB Z(B$)

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

M = M + C * 2 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS “; M

END SUB

DECLARE SUB Z(B$)

CLS

INPUT “ENTER A BINARY NUMBER”; B$

CALL Z(B$)

END

SUB Z(B$)

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

M = M + C * 2 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS “; M

END SUB

**Using declare function procedure**

‘THIS PROGRAM CONVERTS
BINARY NUMBER TO DECIMAL

DECLARE FUNCTION Z (B$)

CLS

INPUT “ENTER A BINARY NUMBER”; B$

PRINT “DECIMAL VALUE IS “; Z(B$)

END

DECLARE FUNCTION Z (B$)

CLS

INPUT “ENTER A BINARY NUMBER”; B$

PRINT “DECIMAL VALUE IS “; Z(B$)

END

FUNCTION Z (B$)

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

M = M + C * 2 ^ P

P = P + 1

NEXT I

Z = M

END FUNCTION

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

M = M + C * 2 ^ P

P = P + 1

NEXT I

Z = M

END FUNCTION

‘THIS PROGRAM CONVERTS
OCTAL TO DECIMAL

CLS

INPUT “ENTER A OCTAL VALUE”; B$

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

D = D + C * 8 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS”; D

END

CLS

INPUT “ENTER A OCTAL VALUE”; B$

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

D = D + C * 8 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS”; D

END

**Using declare function procedure**

‘THIS PROGRAM CONVERTS
OCTAL TO DECIMAL

DECLARE FUNCTION Z (B$)

CLS

INPUT “ENTER A OCTAL VALUE”; B$

PRINT “DECIMAL VALUE IS”; Z(B$)

END

DECLARE FUNCTION Z (B$)

CLS

INPUT “ENTER A OCTAL VALUE”; B$

PRINT “DECIMAL VALUE IS”; Z(B$)

END

FUNCTION Z (B$)

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

D = D + C * 8 ^ P

P = P + 1

NEXT I

Z = D

END FUNCTION

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

D = D + C * 8 ^ P

P = P + 1

NEXT I

Z = D

END FUNCTION

**Using declare sub procedure**

‘THIS PROGRAM CONVERTS
OCTAL TO DECIMAL

DECLARE SUB Z(B$)

CLS

INPUT “ENTER A OCTAL VALUE”; B$

CALL Z(B$)

END

SUB Z(B$)

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

D = D + C * 8 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS”; D

END SUB

DECLARE SUB Z(B$)

CLS

INPUT “ENTER A OCTAL VALUE”; B$

CALL Z(B$)

END

SUB Z(B$)

FOR I = LEN(B$) TO 1 STEP -1

A$ = MID$(B$, I, 1)

C = VAL(A$)

D = D + C * 8 ^ P

P = P + 1

NEXT I

PRINT “DECIMAL VALUE IS”; D

END SUB

CLS

R = 1

INPUT “ENTER A NUMBER”;N

WHILE N<>0

A = N MOD 10

R = R * A

N = FIX ( N / 10 )

WEND

PRINT “PRODUCT OF DIGITS IS”;R

END

R = 1

INPUT “ENTER A NUMBER”;N

WHILE N<>0

A = N MOD 10

R = R * A

N = FIX ( N / 10 )

WEND

PRINT “PRODUCT OF DIGITS IS”;R

END

**Using declare sub procedure**

DECLARE SUB C(N)

CLS

INPUT “ENTER A NUMBER”;N

CALL C(N)

END

SUB C(N)

R = 1

WHILE N<>0

A = N MOD 10

R = R * A

N = FIX ( N / 10 )

WEND

PRINT “PRODUCT OF DIGITS IS”;R

END SUB

CLS

INPUT “ENTER A NUMBER”;N

CALL C(N)

END

SUB C(N)

R = 1

WHILE N<>0

A = N MOD 10

R = R * A

N = FIX ( N / 10 )

WEND

PRINT “PRODUCT OF DIGITS IS”;R

END SUB

**Using declare function procedure**

DECLARE FUNCTION C(N)

CLS

INPUT “ENTER A NUMBER”;N

PRINT “PRODUCT OF DIGITS IS”;C(N)

END

FUNCTION C(N)

R = 1

WHILE N<>0

A = N MOD 10

R = R * A

N = FIX ( N / 10 )

WEND

C = R

END FUNCTION

CLS

INPUT “ENTER A NUMBER”;N

PRINT “PRODUCT OF DIGITS IS”;C(N)

END

FUNCTION C(N)

R = 1

WHILE N<>0

A = N MOD 10

R = R * A

N = FIX ( N / 10 )

WEND

C = R

END FUNCTION

CLS

INPUT “ENTER A NUMBER”;N

WHILE N<>0

A = N MOD 10

R = R + A

N = FIX ( N / 10 )

WEND

PRINT “SUM OF DIGITS IS”;R

END

INPUT “ENTER A NUMBER”;N

WHILE N<>0

A = N MOD 10

R = R + A

N = FIX ( N / 10 )

WEND

PRINT “SUM OF DIGITS IS”;R

END

**Using declare function procedure**

DECLARE FUNCTION C(N)

CLS

INPUT “ENTER A NUMBER”;N

PRINT “SUM OF DIGITS IS”;C(N)

END

FUNCTION C(N)

WHILE N<>0

A = N MOD 10

R = R + A

N = FIX ( N / 10 )

WEND

C = R

END FUNCTION

CLS

INPUT “ENTER A NUMBER”;N

PRINT “SUM OF DIGITS IS”;C(N)

END

FUNCTION C(N)

WHILE N<>0

A = N MOD 10

R = R + A

N = FIX ( N / 10 )

WEND

C = R

END FUNCTION

**Using declare sub procedure**

DECLARE SUB C(N)

CLS

INPUT “ENTER A NUMBER”;N

CALL C(N)

END

SUB C(N)

WHILE N<>0

A = N MOD 10

R = R + A

N = FIX ( N / 10 )

WEND

PRINT “SUM OF DIGITS IS”;R

END SUB

CLS

INPUT “ENTER A NUMBER”;N

CALL C(N)

END

SUB C(N)

WHILE N<>0

A = N MOD 10

R = R + A

N = FIX ( N / 10 )

WEND

PRINT “SUM OF DIGITS IS”;R

END SUB

**Program to print fibonacci series in Qbasic**

Write a program in
Qbasic to print the fibonacci series up to tenth term. Using loops-FOR…NEXT &
WHILE…WEND Fibonacci series is the series in which the next number is obtained
by the sum of two number just front of it. The first two numbers are explained
by the user.It can be obtained up to any term.Here, I am only doing of tenth
term.You can change the number of output to any term just by changing the
looping number.Here is example of a fibonacci series. suppose you entered the
first two numbers-1 & 2 and upto the tenth term then your output will be
as:

1,2,3,5,8,13,21,34,55,89

Here in the begining 1 & 2 are the entered numbers.3 is the product of 1 & 2 as the definition of fibonacci series given in first.like wise 5 is the sum of 2 & 3 and 8 is the sum of 3 & 5 and so on..You can Download the source file.Here is the program.

1,2,3,5,8,13,21,34,55,89

Here in the begining 1 & 2 are the entered numbers.3 is the product of 1 & 2 as the definition of fibonacci series given in first.like wise 5 is the sum of 2 & 3 and 8 is the sum of 3 & 5 and so on..You can Download the source file.Here is the program.

**Using FOR…NEXT**
CLS

A = 1

B = 2

PRINT A

PRINT B

FOR I = 1 TO 10

C = A + B

PRINT C

A = B

B = C

NEXT I

END

A = 1

B = 2

PRINT A

PRINT B

FOR I = 1 TO 10

C = A + B

PRINT C

A = B

B = C

NEXT I

END

**Using WHILE…WEND**

CLS

I = 1

A = 1

B = 2

PRINT A

PRINT B

WHILE I < = 10

C = A + B

PRINT C

A = B

B = C

I = I + 1

WEND

END

I = 1

A = 1

B = 2

PRINT A

PRINT B

WHILE I < = 10

C = A + B

PRINT C

A = B

B = C

I = I + 1

WEND

END

**Using declare sub procedure**

**Using FOR…NEXT**

DECLARE SUB FIB ()

CLS

CALL FIB

END

SUB FIB

A = 1

B = 2

PRINT A

PRINT B

FOR I = 1 TO 10

C = A + B

PRINT C

A = B

B = C

NEXT I

END SUB

CLS

CALL FIB

END

SUB FIB

A = 1

B = 2

PRINT A

PRINT B

FOR I = 1 TO 10

C = A + B

PRINT C

A = B

B = C

NEXT I

END SUB

**Using WHILE…WEND**

DECLARE SUB FIB ()

CLS

CALL FIB

END

SUB FIB

I = 1

A = 1

B = 2

PRINT A

PRINT B

WHILE I < = 10

C = A + B

PRINT C

A = B

B = C

I = I + 1

WEND

END SUB

CLS

CALL FIB

END

SUB FIB

I = 1

A = 1

B = 2

PRINT A

PRINT B

WHILE I < = 10

C = A + B

PRINT C

A = B

B = C

I = I + 1

WEND

END SUB

‘PROGRAM TO CHECK
WHETHER A GIVEN NUMBER IS PRIME OR COMPOSITE

CLS

INPUT “ENTER A NUMBER”;N

FOR I = 2 TO N/2

IF N MOD I = 0 THEN

C = C+2

END IF

NEXT I

IF C>0 THEN

PRINT “IT IS COMPOSITE”

ELSE

? “IT IS PRIME”

END IF

END

CLS

INPUT “ENTER A NUMBER”;N

FOR I = 2 TO N/2

IF N MOD I = 0 THEN

C = C+2

END IF

NEXT I

IF C>0 THEN

PRINT “IT IS COMPOSITE”

ELSE

? “IT IS PRIME”

END IF

END

**Using declare sub procedure**

‘CHECK WHETHER A GIVEN
NUMBER IS PRIME OR COMPOSITE

DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”;N

CALL A(N)

END

DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”;N

CALL A(N)

END

SUB A(N)

FOR I = 2 TO N/2

IF N MOD I = 0 THEN

C = C+2

END IF

NEXT I

IF C>0 THEN

PRINT “IT IS COMPOSITE”

ELSE

? “IT IS PRIME”

END IF

END SUB

FOR I = 2 TO N/2

IF N MOD I = 0 THEN

C = C+2

END IF

NEXT I

IF C>0 THEN

PRINT “IT IS COMPOSITE”

ELSE

? “IT IS PRIME”

END IF

END SUB

**Using declare function procedure**

‘PROGRAM TO CHECK
WHETHER A GIVEN NUMBER IS PRIME OR COMPOSITE

DECLARE FUNCTION AB (N)

CLS

INPUT “ENTER A NUMBER”; N

IF AB(N) > 0 THEN

PRINT “IT IS COMPOSITE”

ELSE

PRINT “IT IS PRIME”

END IF

END

DECLARE FUNCTION AB (N)

CLS

INPUT “ENTER A NUMBER”; N

IF AB(N) > 0 THEN

PRINT “IT IS COMPOSITE”

ELSE

PRINT “IT IS PRIME”

END IF

END

FUNCTION AB (N)

FOR I = 2 TO N / 2

IF N MOD I = 0 THEN

C = C + 2

END IF

NEXT I

AB = C

END FUNCTION

FOR I = 2 TO N / 2

IF N MOD I = 0 THEN

C = C + 2

END IF

NEXT I

AB = C

END FUNCTION

Thursday, May 19, 2011

*1)Write a program to enter your name and print it .*

*CLS*

*Input 'Enter you name';n$*

*Print 'The name is';n$*

*End*

*2)Write a program to enter your name, city, country, age and print them.*

*CLS*

*Input " Enter the name ";N$*

*Input " Enter the city";C$*

*Input " Enter the country";CO$*

*Input " Enter the age";A*

*Print " The name is ";N$*

*Print " The city is ";C$*

*Print " The country is ";CO$*

*Print " The age is ";A*

*End*

*3)Write a program to find the area of rectangle.*

*Cls*

*Input " enter the length " ;l*

*Input " enter the breadth " ;b*

*let A = l*b*

*Print" the area of rectangle=" ;a*

*End*

*4)Write a program to find the area of the triangle.*

*Cls*

*Input " enter the base" ;b*

*Input " enter the height" ;h*

*let T = 1/2*b*h*

*Print" The area of triangle=" ;T*

*End*

*5)Write a program to find the area of the circle.*

*Cls*

*Input" Enter the radius " ;R*

*Let C=22/7*R^2*

*Print " The area of circle =" ;C*

*End*

*6)Write a program to find the circumference of the circle.*

*Cls*

*Input" Enter the radius " ;R*

*Let Circumference=22/7*R*2*

*Print " The area of circle =" ;Circumference*

*End*

*7)Write a program to find the area of the square.*

*Cls*

*Input" Enter the number" ;n*

*Let square= n^2*

*Print" The area of square=" ;Square*

*End*

*8)Write a program to find the area of the square and cube.*

*Cls*

*Input" Enter the number" ;n*

*Let square= n^2*

*Let Cube = n^3*

*Print" The area of square=" ;Square*

*Print" The area of cube=" ; Cube*

*End*

*9)Write a program to find the volume of the box.*

*Cls*

*Input " enter the length " ;l*

*Input " enter the breadth " ;b*

*Input " enter the height " ;h*

*Let Volume= l*b*h*

*Print" The volume of box =" ;Volume*

*End*

*10)Write a program to convert the weight from kilogram to pounds.*

*CLS*

*Input"Enter the weight in kilogram";K*

*Let P=K*2.2*

*Print "The pound is ";P*

*End*

*11)Write a program to convert the distance from kilometer to miles.*

*Cls*

*Input"Enter the length in kilometer";K*

*Let M= K / 1.6*

*Print "The length in miles =";M*

*End*

*12)Write a program to convert the distance from miles to kilomiles.*

*Cls*

*Input " Enter the length in miles";M*

*Let K=M*1.6*

*Print" The length in kilo miles=";K*

*End*

*13)Write a program to enter the initial mileage(m1) and final mileage (m2) then calculate the distance traveled.*

*CLS*

*Input "Enter the Initial Mileage";M1*

*Input "Enter the Final Mileage";M2*

*Let D= M2-M1*

*Print " The distance covered=";D*

*End*

*14)Write a program to find out the simple Interest.*

*Cls*

*Input " Enter the Principal";P*

*Input " Enter the Rate";R*

*Input " Enter the Time";T*

*Let I = P*T*R/100*

*Print " The simple Interest = ";I*

*End*

*15)Write a program to find out the simple Interest and the Amount.*

*Cls*

*Input " Enter the Principal";P*

*Input " Enter the Rate";R*

*Input " Enter the Time";T*

*Let I = P*T*R/100*

*Let A= P + I*

*Print " The simple Interest = ";I*

*Print " The amount=";A*

*End*

*16)Write any number and find it's half.*

*Cls*

*Input "Enter the desired number "; N*

*Let H = N/2*

*Print "The half of the number = ";H*

*END*

*17)Write a program to find the area of four walls of a room.*

*Cls*

*Input"Enter the height ";H*

*Input"Enter the length "; L*

*Input"Enter the Breadth";B*

*Let A= 2 * H * (L+B)*

*Print " The area of four walls =";A*

*End*

*18)Write a program to find the perimeter of a rectangle.*

*Cls*

*Input " enter the length " ;l*

*Input " enter the breadth " ;b*

*Let P=2*(l+b)*

*Print" The perimeter of rectangle=" ;P*

*End*

*19)Write a program to enter any three numbers,sum and the average.*

*Cls*

*Input " Enter any number" ;A*

*Input " Enter any number" ;B*

*Input " Enter any number" ;C*

*Let Sum = A+B+C*

*Let Average =Sum/3*

*Print" The sum=" ;Sum*

*Print" The Average is " ;Average*

*End*

*20)Write a program to enter any two numbers their Sum,Product and the Difference.*

*CLS*

*Input " Enter any number" ;A*

*Input " Enter any number" ;B*

*Let Sum = A+B*

*Let Difference= A-B*

*Let Product = A*B*

*Print" the sum =" ;Sum*

*Print" the Difference =" ;Difference*

*Print" the Product =" ; Product*

*End*

*21)Write a program to find the average of three different numbers.*

*Cls*

*Input" Enter the number " ;A*

*Input" Enter the number " ;B*

*Input" Enter the number " ;C*

*Let Avg= (A+B+C)/3*

*Print" The average=" ;Avg*

*End*

*22)Write a program to input student's name,marks obtained in four different subjects,find the total and average marks.*

*Cls*

*Input" Enter the name " ;N$*

*Input" Enter the marks in English" ;E*

*Input" Enter the marks in Maths" ;M*

*Input" Enter the marks in Science" ;S*

*Input" Enter the marks in Nepali" ;N*

*Let S=E+M+S+N*

*Let A=S/4*

*Print " The name of the student is" ;N$*

*Print " The total marks is" ;S*

*Print " The Average marks" ;A*

*End*

*23)Write a program to find 10%,20% and 30% of the input number.*

*Cls*

*Input" Enter any number" ;N*

*Let T=10/100*N*

*Let Twe=20/100*N*

*Let Thi=30/100*N*

*Print " 10%of input number=" ;T*

*Print " 20%of input number=" ;Twe*

*Print " 30%of input number=" ;Thi*

*End*

*24)Write a program to convert the distance to kilometer to miles.*

*Cls*

*Input" Enter the kilometer" ;K*

*Let M=K/1.6*

*Print " The miles = " ;M*

*End*

*25)Write a program to find the perimeter of square.*

*Cls*

*Input “Enter the length”; L*

*Let P =4 * L*

*Print “ The perimeter of square=”;P*

*End*

*26)Write a program to enter the Nepalese currency and covert it to Indian Currency.*

*CLS*

*Input “Enter the Nepalese currency” ;N*

*Let I = N * 1.6*

*Print “the Indian currency=”;I*

*End*

*27)Write a program to enter the Indian currency and covert it to Nepalese Currency.*

*CLS*

*Input “Enter the Indian currency” ;N*

*Let N = I / 1.6*

*Print “the Nepalese currency=”;I*

*End*

*28)Write a program to enter any number and find out whether it is negative or positive.*

*CLS*

*Input “Enter the number”; N*

*If N>0 Then*

*Print “ The number is positive”*

*Else*

*Print “The number is negative”*

*EndIf*

*End*

*29)Write a program to enter any number and find out whether it is even or odd using select case statement.*

*Cls*

*Input “Enter any number” ;N*

*R=N mod 2*

*Select case R*

*Case = 0*

*Print “The number is Even number”*

*Case Else*

*Print “The number is odd number”*

*End Select*

*End*

*30)Write a program to check the numbers between 1 & 3.*

*Cls*

*Input “Enter the numbers between 1-3”;N*

*Select case N*

*Case 1*

*Print “It’s number 1”;*

*Case 2*

*Print “It’s a number 2”;*

*Case 3*

*Print “It’s a number 3”*

*Case else*

*Print “It’s out of range”;*

*End select*

*End*

*31)Write a program to enter any alphabet and test alphabet is ‘a’ or not using the select case statement.*

*Cls*

*Input “Enter the alphabet”;A$*

*A$=UCase$ (A$)*

*Select Case A$*

*Case ‘A’*

*Print “It’s alphabet A”*

*Case Else*

*Print “It’s not alphabet A”*

*End Select*

*End*

*32)Write a program to enter any alphabet and find out whether the number is vowel or alphabet.*

*Cls*

*Input “Enter Letters/Alphabet”;A$*

*A$ = UCase $ (A$)*

*Select case A$*

*Case “A”, “E”, “I”, “O”, “U”*

*Print “Its’ a vowel”*

*Case Else*

*Print “ It’s not a vowel”*

*End Select*

*End*

*33)Generate the following numbers using For….Next…..Loop.*

*1,2,3,4,…,50*

*CLS*

*For I = 1 to 50 Step 1*

*Print I*

*Next I*

*End*

*34)Generate the following numbers using For….Next…..Loop.*

*1,3,5,7,9,....99*

*Cls*

*For I = 1 to 99 Step 2*

*Print I*

*Next I*

*End*

*35)Generate the following numbers using For….Next…..Loop.*

*2,4,6,8,10,…50*

*Cls*

*For I = 2 to 50 Step 2*

*Print I*

*Next I*

*End*

*36)Generate the following numbers using For….Next…..Loop.*

*1,3,5,7,…99*

*ClsFor I = 1 to 99 Step 2*

*Print I*

*Next I*

*End*

*37)Generate the following numbers using For….Next…..Loop.*

*5,10,15,…90*

*Cls*

*For I = 5 to 90 Step 5*

*Print I*

*Next I*

*End*

*38) Generate the following numbers using For….Next…..Loop.*

*10,20,30,40,…100.*

*Cls*

*For I = 10 to 100 Step 10*

*Print I*

*Next I*

*End*

*39)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.*

*Cls*

*I = 1*

*While I<=100*

*Print I ;*

*I = I + 1*

*WEND*

*END*

*40)Generate the following numbers using For….Next…..Loop.*

*2,4,6,8,10….50*

*CLS*

*I = 2*

*While I < =50*

*Print I;*

*I = I + 2*

*WEND*

*END*

*41)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.*

*1,3,5,7,9,…99*

*CLS*

*I = 1*

*While I <=99*

*Print I;*

*I = I + 2*

*WEND*

*END*

*42)Write a program to print numbers stated below USING WHILE…WEND STATEMENT.*

*1,4,9,…upto 10th term.*

*CLS*

*I=1*

*While I < =10*

*Print I^2;*

*I = I + 1*

*WEND*

*END*

1) WAP
to print the Fibonacci series

CLS

a = 1

b = 1

PRINT a, b,

FOR i = 1 TO 8

c = a + b

PRINT c,

a = b

b = c

NEXT i

END

……………………………………………………………………………….

CLS

a = 1

b = 1

PRINT a, b,

FOR i = 1 TO 8

c = a + b

PRINT c,

a = b

b = c

NEXT i

END

……………………………………………………………………………….

2) WAP
to print the factors of a given number

REM Program to print the factors of a given number

CLS

INPUT “Enter any number”; n

FOR i = 1 TO n

IF n MOD i = 0 THEN PRINT i,

NEXT i

END

…………………………………………………………………………………

REM Program to print the factors of a given number

CLS

INPUT “Enter any number”; n

FOR i = 1 TO n

IF n MOD i = 0 THEN PRINT i,

NEXT i

END

…………………………………………………………………………………

3) WAP
to print the greater among ten different numbers

REM
Program to print greater number among ten different numbers

CLS

INPUT “Enter first number”; g

FOR i = 2 TO 10

INPUT “Enter next number”; a

IF a > g THEN g = a

NEXT

PRINT g; ” is the greatest number”

END

CLS

INPUT “Enter first number”; g

FOR i = 2 TO 10

INPUT “Enter next number”; a

IF a > g THEN g = a

NEXT

PRINT g; ” is the greatest number”

END

………………………………………………………………………………….

4) WAP to print the greater among three different numbers

4) WAP to print the greater among three different numbers

REM
Program to print greater among three different numbers

CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

INPUT “Enter third number”; c

IF a > b AND a > c THEN

PRINT a; ” is greater”

ELSEIF b > a AND b > c THEN

PRINT b; ” is greater”

ELSE

PRINT c; ” is greater”

END IF

END

…………………………………………………………………………….

CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

INPUT “Enter third number”; c

IF a > b AND a > c THEN

PRINT a; ” is greater”

ELSEIF b > a AND b > c THEN

PRINT b; ” is greater”

ELSE

PRINT c; ” is greater”

END IF

END

…………………………………………………………………………….

5) WAP
to print the greater among two different numbers

REM
Program to print the greater among two different numbers

CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

IF a > b THEN

PRINT a; ” is greater”

ELSE

PRINT b; ” is greater”

END IF

END

………………………………………………………………………………..

6) WAP to calculate the cube root of a given number

REM Program to calculate the cube root of a given number

CLS

INPUT “Enter any number”; n

c = n ^ (1 / 3)

PRINT “Cube root of “; n; ” is “; s

END

…………………………………………………………………………………..

CLS

INPUT “Enter first number”; a

INPUT “Enter second number”; b

IF a > b THEN

PRINT a; ” is greater”

ELSE

PRINT b; ” is greater”

END IF

END

………………………………………………………………………………..

6) WAP to calculate the cube root of a given number

REM Program to calculate the cube root of a given number

CLS

INPUT “Enter any number”; n

c = n ^ (1 / 3)

PRINT “Cube root of “; n; ” is “; s

END

…………………………………………………………………………………..

7) WAP
to calculate the square root of a given number

REM
Program to calculate the square root of a given number

CLS

INPUT “Enter any number”; n

s = SQR(n)

PRINT “Square root of “; n; ” is “; s

END

================================================

1)Program to check the given number for palindrome in qbasic using declare sub

CLS

INPUT “Enter any number”; n

s = SQR(n)

PRINT “Square root of “; n; ” is “; s

END

================================================

1)Program to check the given number for palindrome in qbasic using declare sub

DECLARE
SUB A (N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A (N)

S = N

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “IT IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A (N)

S = N

WHILE N <> 0

B = N MOD 10

R = R * 10 + B

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “IT IS PALINDROME”

ELSE

PRINT “IT IS NOT PALINDROME”

END IF

END SUB

………………………………………………………………………………..

2) Program to check given number for armstrong in qbasic using declare sub

DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

S=N

WHILE N <> 0

B = N MOD 10

R = R + B ^ 3

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

END SUB

………………………………………………………………………………….

2) Program to check given number for armstrong in qbasic using declare sub

DECLARE SUB A(N)

CLS

INPUT “ENTER A NUMBER”; N

CALL A(N)

END

SUB A(N)

S=N

WHILE N <> 0

B = N MOD 10

R = R + B ^ 3

N = FIX(N / 10)

WEND

IF S = R THEN

PRINT “THE GIVEN NUMBER IS ARMSTRONG”

ELSE

PRINT “IT IS NOT ARMSTRONG”

END IF

END SUB

………………………………………………………………………………….

3)
Program to reverse a given string in qbasic

CLS

INPUT “ENTER A STRING”; S$

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END

INPUT “ENTER A STRING”; S$

FOR I = LEN(S$) TO 1 STEP -1

M$ = MID$(S$, I, 1)

REV$ = REV$ + M$

NEXT I

PRINT REV$

END

………………………………………………………………………………..

4)
Program to convert decimal to binary in qbasic using declare function

‘THIS
PROGRAM CONVERTS DECIMAL NUMBER TO BINARY

DECLARE FUNCTION A$ (N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “BINARY EQUIVALENT IS”; A$(N)

END

DECLARE FUNCTION A$ (N)

CLS

INPUT “ENTER A NUMBER”; N

PRINT “BINARY EQUIVALENT IS”; A$(N)

END

FUNCTION
A$ (N)

WHILE N <> 0

E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

A$=C$

END FUNCTION

………………………………………………………………………………….

5) Program to convert decimal to octal in qbasic

WHILE N <> 0

E = N MOD 2

B$ = STR$(E)

N = FIX(N / 2)

C$ = B$ + C$

WEND

A$=C$

END FUNCTION

………………………………………………………………………………….

5) Program to convert decimal to octal in qbasic

THIS
PROGRAM CONVERTS DECIMAL NUMBER TO Octal

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

PRINT “QUAINARY EQUIVALENT IS”; C$

END

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 8

B$ = STR$(A)

N = FIX(N /

C$ = B$ + C$

WEND

PRINT “QUAINARY EQUIVALENT IS”; C$

END

……………………………………………………………………………….

6)Program
to reverse a given number in qbasic

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 10

R = R * 10 + A

N = FIX(N / 10)

WEND

PRINT R

END

………………………………………………………………………………..

Programming for SLC board

CLS

INPUT “ENTER A NUMBER”; N

WHILE N <> 0

A = N MOD 10

R = R * 10 + A

N = FIX(N / 10)

WEND

PRINT R

END

………………………………………………………………………………..

Programming for SLC board

1. Write
a program to print the sum of the two numbers passed as parameters

2. Write a program to calculate the area of a circle where radius is passed as a parameter

3. Write a program to calculate the volume of a cylinder where pi=3.14 declared as a global variable and radius of its base is passed as the parameter.

4. Write a program to calculate the simple interest where the principal, time and rate are passed as parameter

5. Write a program to determine whether a man has profit or loss where cost price and selling price are given

6. Write a program to convert calcius temperature to Fahrenheit temperature

2. Write a program to calculate the area of a circle where radius is passed as a parameter

3. Write a program to calculate the volume of a cylinder where pi=3.14 declared as a global variable and radius of its base is passed as the parameter.

4. Write a program to calculate the simple interest where the principal, time and rate are passed as parameter

5. Write a program to determine whether a man has profit or loss where cost price and selling price are given

6. Write a program to convert calcius temperature to Fahrenheit temperature

Lab
Session 2:

7. Write a program to create a sub procedure to print the following series

a. 1,3,4,7,11————-upto 8th terms

b. 2,22,222,2222,2222

c. 11111,1111,111,11,1

d. 1000,500,250,125

e. 1,1,2,3,5,8, ——–upto 8th terms

f. 2,4,8,16 ——— upto 10th terms

g. 1,4,9,16,————– upto 8th terms

h. 0.1,0.03,0.005,0.007, ——- upto 8th terms

i. 3,9,27,81, ———— upto 6th terms

j. 0.1,0.22,0.333,0.4444,0.55555

k. 1,22,333,4444,55555

l. 7,22,11,34,17,52,26,13,40,20,10

—————————————————————————————————

7. Write a program to create a sub procedure to print the following series

a. 1,3,4,7,11————-upto 8th terms

b. 2,22,222,2222,2222

c. 11111,1111,111,11,1

d. 1000,500,250,125

e. 1,1,2,3,5,8, ——–upto 8th terms

f. 2,4,8,16 ——— upto 10th terms

g. 1,4,9,16,————– upto 8th terms

h. 0.1,0.03,0.005,0.007, ——- upto 8th terms

i. 3,9,27,81, ———— upto 6th terms

j. 0.1,0.22,0.333,0.4444,0.55555

k. 1,22,333,4444,55555

l. 7,22,11,34,17,52,26,13,40,20,10

—————————————————————————————————

Lab
Session 3

Create sub procedures to print the following patterns

1

12

123

1234

12345

Create sub procedures to print the following patterns

1

12

123

1234

12345

1

22

333

4444

55555

22

333

4444

55555

11111

2222

333

44

5

2222

333

44

5

1

2 3

4 5 6

7 8 9 10

11 12 13 14 15

2 3

4 5 6

7 8 9 10

11 12 13 14 15

* * * *
*

* * * *

* * *

**

*

* * * *

* * *

**

*

*

* *

* *

* *

*

* *

* *

* *

*

54321

5432

543

54

5

5432

543

54

5

12345

1234

123

12

1

1234

123

12

1

55555

4444

333

22

1

4444

333

22

1

10 20 30

20 30 40

30 40 50

40 50 60

20 30 40

30 40 50

40 50 60

KAMAL

KAMA

KAM

KA

K

KAMA

KAM

KA

K

can yo give me solution for program to check an integer is +ve or -ve.

ReplyDeletecan you give me solution to print 100, 81, 64, .......7th term

ReplyDelete