-->
Showing posts with label dry run table. Show all posts
Showing posts with label dry run table. Show all posts

Tuesday, June 10, 2025

Qbasic program to get output using dry run table | SEE computer science programming guide in Qbasic -to find sum of numbers divisible by 4

 

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



QBasic program to know the output of program using dry run table- to find the sum of numbers between 1 and 20 and which are divisible by 4, using sub procedure



declare sub sum(A)

A = 2

Call sum(A)

End

Sub sum (A)

    While A <= 20

        If A Mod 4 = 0 Then

            s = s + A

        End If

        A = A + 1

    Wend

    Print s

End Sub

Dry run table

A

While A<=20

        If A Mod 4 = 0

S=s+A

A=A+1

2

yes

no

 

A=3

3

yes

no

 

A=4

4

yes

yes

S=s+A=0+4=4

A=5

5

yes

no

 

A=6

6

yes

no

 

A=7

7

yes

no

 

A=8

8

y

yes

S=4+8=12

A=9

9

yes

n

 

=10

10

yes

n

 

=11

11

yes

N

 

=12

12

yes

y

=12+12=24

A=13

13

yes

n

 

=14

14

yes

n

 

=15

15

yes

n

 

=16

16

yes

y

=24+16=40

=17

17

yes

n

 

=18

18

yes

n

 

=19

19

yes

n

 

=20

20

yes

y

=40+20=60

21

21

no

 

 

 


output:60

Qbasic program to get output using dry run table | SEE computer science programming guide in Qbasic -to find sum of 1 to 9 with 2 step increment

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


QBasic program to know the output of program using dry run table- to find the sum of numbers between 1 and 9 using function procedure

declare function find()

Print find

End

Function find ()

    For n = 1 To 9 Step 2

        Let s = s + n

    Next n

    find = s

End Function

Dry run table

N=1 to 9 step 2

S=s+n

find

 

N=1;true

S=0+1=1

 

 

N=3;true

S=1+3=4

 

 

N=5;true

S=4+5=9

 

 

N=7;true

S=9+7=16

 

 

N=9;true

S=s+N=16+9=25

 

 

N=11;false

 

Find=s=25

 


output

25

Qbasic program to get output using dry run table | SEE computer science programming guide in Qbasic - for given numeric pattern 5,55,555


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


QBasic program to know the output of program using dry run table- to print the numeric pattern 5,55,555 etc

'CDC model question set 1

declare sub Result()

Call result

End

Sub result ()

    N = 5

    C = 1

    While C <= 5

        Print N

        N = N * 10 + 5

        C = C + 1

    Wend

End Sub


Dry run table with output


N

C

C<=5

Print N

N=N*10+5

C=c+1

5

1

yes

5

=5*10+5=55

2

55

2

yes

55

=55*10+5=555

3

555

3

yes

555

=555*10+5=55555

4

5555

4

yes

5555

=5555*10+5=55555

5

55555

5

yes

55555

=55555*10+5=555555

6

555555

6

no

 

 

 


output:

5

55

555

5555

55555


Monday, June 9, 2025

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

 

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


QBasic program to know the output of program using dry run table- to extract characters and print them


DECLARE FUNCTION OUTPUTT$(W$)

Cls

W$ = "CRIMES"

Print OUTPUTT$(W$)

End

Function OUTPUTT$ (W$)

    For M = Len(W$) To 1 Step -2

        M$ = M$ + Mid$(W$, M, 1)

    Next M

    OUTPUTT$ = M$

End Function


DRYRUN table for above program is given below

W$

M=6 TO 1 STEP-2

M$=M$+MID$(W$,M,1)

OUTPUTTT$

 

 

CRIMES

M=6

M$=S

 

 

 

 

M=4

M$=S+M=SM

 

 

 

 

M=2

M$=SM+R=SMR

SMR

 

 

Output:-

SMR

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

 


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





QBasic program to know the output of program using dry run table- to print the characters from given string.


DECLARE SUB RESULT(A$)

Cls

A$ = "KATHMANDU"

Call RESULT(A$)

End

Sub RESULT (A$)

    For C = 1 To Len(A$) Step 2

        X$ = Mid$(A$, C, 1)

        Print X$;

    Next C

End Sub


DRYRUN for above program

A$

C=1 TO 9 STEP 2

X$=MID$(A$,C,1)

PRINT X$;

 

 

KATHMANDU

C=1

X$=K

K

 

 

 

C=3

X$=T

T

 

 

 

C=5

X$=M

M

 

 

 

C=7

X$=N

N

 

 

 

C=9

X$=U

U

 

 

Output:-

KTMNU

Sunday, June 8, 2025

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

 


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



QBasic program to know the output of program using dry run table- to count total words.

declare function wordcount%(s$)
Cls
Input "enter a sentence", line$
Print "total words=", wordcount%(line$)
End
Function wordcount% (s$)
    count = 1
    For i = 1 To Len(s$)
        If Mid$(s$, i, 1) = " " Then
            count = count + 1
        End If
    Next i
    wordcount% = count

End Function


output:

 Dry run table for ouput is given below.
IF we take the input Hello how are you?,

S$

Count

I= 1 to len(s$)[17]

Mid$(s$,I,1)= “ “

 

Hello how are you?

1

I=1

No upto five times

 

 

 

I=6

Yes, count=2

 

 

 

I=7/8/9

no

 

 

 

I=10

Yes, count=3

 

 

 

I=11/12/13

no

 

 

 

I=14

Yes,count=4

 

 

 

I=15/16/17

no

 


output is
4