Solve the Qbasic program
Attachments:
Answers
Answered by
3
Language :
QBasic
Program:
CLS
INPUT "enter the height: "; h
FOR i = 1 to h
a$="* "
b$="$ "
FOR j=1 to i
PRINT a$;
c$= a$
a$=b$
b$=c$
NEXT j
NEXT i
END
Output:
Consider the attachment.
Explanation:
- The "*" and "$" are stored in a variable under first for loop since we want the number to always start printing from "*" followed by "$".
- The 2nd for loop print these by swapping values. c stores value of a , b stores value of a and a stores the final value of c. Thus successfully swapping the values.
- Print something ; : prints stuff in the same line.
- Print : Returns new line.
Attachment:
Attachments:
Similar questions