Computer for SEE and NEB

It is a complete SEE and NEB solution for computer science. It includes Computer Fundamentals, Database (SQL), Programming in C QBASIC, CSS, JavaScript, and PHP for beginners.

Breaking

Post Top Ad

Your Ad Spot

Wednesday, February 23, 2022

String pattern in QBASIC

 

String pattern in QBASIC


1)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

FOR x = 1 TO LEN(a$)

PRINT LEFT$(a$, x)

NEXT x

END SUB

 

Q

QB

QBA

QBAS

QBASI

QBASIC

 

2)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

FOR x = 1 TO LEN(a$)

PRINT LEFT$(a$, x)

NEXT x

END SUB

QBASIC

QBASI

QBA

QB

Q

 

Also Read: Two-Dimensional Array in QBASIC

3)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

FOR x = 1 TO LEN(a$)

PRINT RIGHT$(a$, x)

NEXT x

END SUB

C

IC

SIC

ASIC

BASIC

QBASIC

 

4)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

FOR x = LEN(a$) TO 1 STEP -1

PRINT RIGHT$(a$, x)

NEXT x

END SUB

QBASIC

BASIC

ASIC

SIC

IC

C

 

5)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

FOR x = 1 TO LEN(a$)

PRINT MID$(a$, x, 1)

NEXT x

END SUB

Q

B

A

S

I

C

 

6)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

FOR x = LEN(a$) TO 1 STEP -1

PRINT MID$(a$, x, 1)

NEXT x

END SUB

C

I

S

A

B

Q

 

7)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

t = 5

FOR x = 1 TO LEN(a$)

PRINT TAB(t); MID$(a$, x, 1)

t = t + 2

NEXT x

END SUB

     


   

 

8)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "QBASIC"

t = 15

FOR x = LEN(a$) TO 1 STEP -1

PRINT TAB(t); MID$(a$, x, 1)

t = t - 2

NEXT x

END SUB

 






9)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "DHANGADHI"

C = 1: T = 30

FOR x = 5 TO 1 STEP -1

PRINT TAB(T); MID$(a$, x, C)

C = C + 2

T = T - 1

NEXT x

END SUB








10)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "DHANGADHI"

C = 9: T = 30

FOR x = 1 TO 5

PRINT TAB(T); MID$(a$, x, C)

C = C - 2

T = T + 1

NEXT x

END SUB









 

11)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "*****"

FOR x = 1 TO 5

PRINT LEFT$(a$, x)

NEXT x

END SUB

*

**

***

****

*****

 

12)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "*****"

FOR x = 5 TO 1 STEP -1

PRINT LEFT$(a$, x)

NEXT x

END SUB

*****

****

***

**

*

 

13)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "*****"

FOR x = 1 TO LEN(a$)

PRINT LEFT$(a$, x)

NEXT

FOR y = 1 TO LEN(a$)

PRINT LEFT$(a$, y)

NEXT

FOR z = 1 TO LEN(a$)

PRINT MID$(a$, z, 1)

NEXT

END SUB

 




 

 

14)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "*********"

C = 9: T = 30

FOR x = 1 TO 5

PRINT TAB(T); MID$(a$, x, C)

C = C - 2

T = T + 1

NEXT x

END SUB






15)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "*********"

C = 1: T = 30

FOR x = 5 TO 1 STEP -1

PRINT TAB(T); MID$(a$, x, C)

C = C + 2

T = T - 1

NEXT x

END SUB

 






16)

DECLARE SUB pat ()

CLS

CALL pat

END

 

SUB pat

a$ = "abcde"

FOR x = 1 TO LEN(a$)

FOR y = 1 TO x

b$ = MID$(a$, x, 1)

IF x MOD 2 = 1 THEN

PRINT UCASE$(b$);

ELSE

PRINT LCASE$(b$);

END IF

NEXT y

PRINT

NEXT x

 END SUB

A

bb

CCC

dddd

EEEEE

 

Also Read: 

Language processor and its types

C program to calculate the sum and average of input two numbers using function

Print the multiplication table of input number in C

C program to display the series of even numbers from 1 to 100

 

No comments:

Post a Comment

Post Top Ad

Your Ad Spot

Pages