-->

Sunday, June 8, 2025

Qbasic program to get output using dry run table | SEE computer science programming guide in Qbasic

 QBasic programs collection-Especially for SEE (Grade-10)


QBasic program to know the output of program using dry run table


declare function onlydigits$(text$)

Cls

Input "enter a string"; s$

Print "the digits in that string ="; onlydigits$(s$)

End

Function onlydigits$ (s$)

    For i = 1 To Len(s$)

        r$ = Mid$(s$, i, 1)

        If r$ >= "0" And r$ <= "9" Then

            digits$ = digits$ + r$

        End If

    Next i

    onlydigits$ = digits$

End Function


Dry run table with output:

If the input is 'Grade 12', the dry run table can  be written as below.

S$

I=1 to len(s$)

1 to 8;

r$= Mid$(s$, i, 1)

if r$ >= "0" And r$ <= "9"

Digits$

Grade 12

i=1

r$=G

no

 

 

I=2

r$=r

no

 

 

I=3

R$=a

no

 

 

I=4

r$=d

No

 

 

I=5

r$=e

No

 

 

I=6

r$=space

No

 

 

I=7

r$=1

yes

Digits$=1

 

I=8

r$=2

yes

Digits$=1+2=12

 

 

 

 

    onlydigits$ = digits$

onlydigits$=12

 

output=12


No comments:

Post a Comment