Paper VII GROUP A: Unit I
Dear MSc Second Year Zoology (V.U) StudentsThis assignment uses string functions to manipulate string in qbasic. Complete this assignment and send it to me by mail. In case you face any difficulties please go through the materials given for further reading. Try to think simple, write few steps and run in qb64, see if it is giving the result the you expect it to. Build the program step-wise.
The following example uses Len() function to calculate length of a string than uses a FOR-NEXT loop to extract increasing number of characters from left of the string with LEFT$() and then prints them. For your assignment you will need to use MID$() its syntax is MID$(S$,x,y) where S$ = variable to which string is assigned to, x = position at which to begin, y = number of characters to extract.
Also note that I have used GOTO statements to make the program follow a particular sequence of steps this is an example of controlling the flow of the program
-
10 Cls
- Write a program to take input student's name then print it in following format.
- Further Reading: A blog with many qbasic examples
- Open WikiBook
20 Input “Enter any name ”;N$
30 NameLength = LEN(N$)
40 IF NameLength > 3 THEN GOTO 70
50 PRINT "Name is too small"
60 GOTO 110
70 FOR i = 1 TO NameLength
80 leftslice$ = LEFT$(N$, i)
90 PRINT leftslice$
100 NEXT i
110End
example: Rosemerry
R
o
s
e
m
e
r
r
y
If you face any problems or you want to discuss this assignment please feel free to leave a comment.
No comments:
Post a Comment