Monday, March 2, 2020

SET 18 - Qbasic Program ----SEE Computer Science 2076 --- Practice Day 18 --- 15 Questions




Group B
1.      Write a program using FUNCTION to get a word from the user and print the word in the reverse order.

 

DECLARE FUNCTION REV$ (S$)

CLS

INPUT "ENTER ANY STRING"; S$

PRINT "REVERSED STRING IS "; REV$(S$)

END

 

FUNCTION REV$ (S$)

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

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

W$ = W$ + B$

NEXT I

REV$ = W$

END FUNCTION

 

Write a program using sub to get a word from the user and print the word in the reverse order.

 

DECLARE SUB REV (S$)

CLS

INPUT "ENTER ANY STRING"; S$

CALL REV(S$)

END

 

SUB REV$ (S$)

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

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

W$ = W$ + B$

NEXT I

PRINT "REVERSED STRING IS "; W$

END FUNCTION

 

 

Write a program using FUNCTION….END FUNCTION to input a string and count the total number of consonants.

 

DECLARE FUNCTION COUNT (S$)

CLS

INPUT "ENTER ANY STRING"; S$

PRINT "TOTAL NO. OF CONSONANTS= "; COUNT(S$)

END

 

FUNCTION COUNT (S$)

CC = 0

FOR I = 1 TO LEN(S$)

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

C$ = UCASE$(B$)

IF C$ <> "A" AND C$ <> "E" AND C$ <> "I" AND C$ <> "O" AND C$ <> "U" THEN CC = CC + 1

NEXT I

COUNT = CC

END FUNCTION

 

Write a program to find the numbers of vowels in an input string using ‘SUB…..END SUB’. 

 

DECLARE SUB COUNT (S$)

CLS

INPUT "ENTER ANY STRING"; S$

CALL COUNT(S$)

END

 

SUB COUNT (S$)

VC = 0

FOR I = 1 TO LEN(S$)

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

C$ = UCASE$(B$)

IF C$ = "A" OR C$ = "E" OR C$ = "I" OR C$ = "O" OR C$ = "U" THEN VC = VC + 1

NEXT I

PRINT "TOTAL NO. OF VOWELS= "; VC

END SUB

 

Write a program using FUNCTION... END FUNCTION to count the number of words in a sentence.

 

DECLARE FUNCTION COUNT (S$)

CLS

INPUT "ENTER ANY STRING"; S$

PRINT "TOTAL NO. OF WORDS= "; COUNT(S$)

END

 

FUNCTION COUNT (S$)

WC = 1

FOR I = 1 TO LEN(S$)

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

IF B$ = " " THEN WC = WC + 1

NEXT I

COUNT = WC

END FUNCTION

 

Write a program to declare SUB procedure to print only the vowels from a given word.

 

DECLARE SUB DISPV (S$)

CLS

INPUT "ENTER ANY STRING"; S$

CALL DISPV(S$)

END

 

SUB DISPV(S$)

FOR I = 1 TO LEN(S$)

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

C$ = UCASE$(B$)

IF C$ = "A" OR C$ = "E" OR C$ = "I" OR C$ = "O" OR C$ = "U" THEN D$=D$+ B$

END IF

NEXT I

PRINT “VOWELS ONY ARE”; D$

END SUB

 

 


Group C
1.      Write a program to test whether the given number is positive or negative using SUB…..END SUB. [SEE MODEL 2065 ], [SLC 2066 S]
2.      Using SUB…END SUB Write a program to test whether the given number is completely divisible by 13 or not. [SLC 2067 R]
3.      Write a program to input three different numbers in the main module and then find the greatest number using SUB…END SUB. [SLC 2068 S]

Group D
1.      Using SUB…END SUB Write a program to print the following series 9,7,5,…1. [SLC 2065 R]
2.      Write a program using SUB…END SUB to print the series 1,1,2,3,5,8… upto ten terms. [SLC 2069 R]
3.      Write a program to print natural numbers from 1 to 5 using SUB…END SUB. [SLC 2069 S]
4.      Write a program using SUB…END SUB to print the first ten odd numbers. [SLC 2071 S]
5.      Write a program to print the sum of digits of a given number using SUB procedure. [SLC 2070 S]
6.      Write a program using a SUB procedure module to print the multiplication table of any input number up to tenth terms.[SEE 2075 S2]

No comments:

Post a Comment