0% found this document useful (0 votes)
2 views

qbasic 2

The document contains four programming subroutines in a BASIC-like language. The first subroutine converts seconds into hours, minutes, and seconds; the second counts and displays vowels and consonants in a given string; the third displays all factors of a given number; and the fourth displays the first ten multiples of a given number.

Uploaded by

kazi.kp345
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
2 views

qbasic 2

The document contains four programming subroutines in a BASIC-like language. The first subroutine converts seconds into hours, minutes, and seconds; the second counts and displays vowels and consonants in a given string; the third displays all factors of a given number; and the fourth displays the first ten multiples of a given number.

Uploaded by

kazi.kp345
Copyright
© © All Rights Reserved
Available Formats
Download as PDF, TXT or read online on Scribd
You are on page 1/ 2

1. To convert given second into respective hour, minute and second.

Declare sub convert (s)


CLS
INPUT “Enter second”;s
call convert (s)
end
sub convert (s)
h =s\3600
rs = s MOD 3600
m = rs\60
sec = rs MOD 60
Print “Hour";h; “Minute”;m; “Second”;sec
End Sub

2. To display and count all the vowels and consonant from the given string.

DECLARE SUB COUNT (N$)


CLS
INPUT "Enter any string"; N$
CALL COUNT (N$)
END
SUB COUNT (N$)
FOR I = 1 TO LEN(N$)
X$ = MID$(N$,I,1)
X$ = UCASE$(X$)
IF X$ = "A" AND X$ = "E" AND X$ = "I" AND X$ = "O" AND X$ = "U" THEN
V = V+1
ELSE
C=C+1
END IF
NEXT I
PRINT "Total numbers of vowels ="; V
PRINT "Total numbers of consonants ="; C
END SUB

3. To display all the factors of given number.

Declare sub factors (n)


cls
Input “ Enter number” ;n
call factors (n)
end
sub factors (n)
for i = 1 to n
If n MOD i = 0 then
print ;i
end if
next i
end sub

4. To display first 10 multiples of given number.

Declare sub multiple (n)


cls
Input “ Enter number” ;n
call multiple (n)
end
sub multiple (n)
for i = 1 to 10
m=n*i
print m;
next i
end sub

You might also like