QBasic Programming

WAP to convert octal number to decimal number

CLS
INPUT "ENTER OCTAL NUMBER"; N$
FOR I = LEN(N$) TO 1 STEP -1
B$ = MID$(N$, I, 1)
S = S + VAL(B$) * 8 ^ P
P = P + 1
NEXT I
PRINT "DECIMAL EQUIVALENT VALUE="; S
END
OR
USING SUB PROCEDURE
DECLARE SUB CONV(N)
CLS
INPUT "ENTER OCTAL NUMBER"; N
CALL CONV(N)
END
SUB CONV(N)
P = 0: S = 0
WHILE N <> 0
R = N MOD 10
S = S + R * 8 ^ P
P = P + 1
N = N \ 10
WEND
PRINT "DECIMAL EQUIVALENT VALUE="; S
END SUB
USING FUNCTION PROCEDURE
DECLARE FUNCTION CONV(N)
CLS
INPUT "ENTER OCTAL NUMBER"; N
PRINT "DECIMAL EQUIVALENT VALUE="; CONV(N)
END
FUNCTION CONV(N)
P = 0: S = 0
WHILE N <> 0
R = N MOD 10
S = S + R * 8 ^ P
P = P + 1
N = N \ 10
WEND
CONV = S
END FUNCTION

WAP to convert decimal number to octal number (Prev Lesson)
(Next Lesson) WAP to convert decimal number to hexadecimal number
Back to QBasic Programming
Notice: compact(): Undefined variable: limits in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

Notice: compact(): Undefined variable: groupby in /home/bhimgautam34/public_html/wp-includes/class-wp-comment-query.php on line 853

No Comments

Post a Reply

Course Curriculum

error: Content is protected !!