Connect Me

twitterfacebookgoogle plus email

  Instagram View Biwas Bhattarai's profile on LinkedIn
Showing posts with label Printing series in QBasic. Show all posts
Showing posts with label Printing series in QBasic. Show all posts

WAP using SUB procedure to print the series, 1, 12, 123, 1234, 12345.

WAP using SUB procedure to print the series, 1, 12, 123, 1234, 12345.

DECLARE SUB SERIES()
CLS
CALL SERIES
END

SUB SERIES()
A=1
B=2
FOR I=1 TO 5
PRINT A
A=(A*10)+B
B=B+1
NEXT I
END SUB

OR ALTERNATIVELY
DECLARE SUB SERIES(A$)
CLS
A$="12345"
CALL SERIES(A$)
END

SUB SERIES(A$)
FOR I=1 TO 5
PRINT LEFT$(A$,I)
NEXT I
END SUB

WAP using SUB procedure to print the series 1, 121, 12321, 1234321, 123454321

WAP using SUB procedure to print the series 1, 121, 12321, 1234321, 123454321

DECLARE SUB SERIES()
CLS
CALL SERIES
END

SUB SERIES()
A&=1
FOR I= 1 TO 5
PRINT A&^2
A&=(A&*10)+1
NEXT I
END


NOTE:
& in A& numeric variable makes it of LONG type. Long..........Non-floating-point numbers from -2,147,483,648 to 2,147,483,647
Examples of a Long Data Type: 560005, 3, -2, 0, -867000, 14, 8, -10
Ą
https://www.flickr.com/photos/spklg/15211044551/