8. Write a programin QBASICtogenerate the pattern given below
1
12
123
1234
Answers
Answered by
5
Answer:
This is the required QBASIC program for the question.
CLS
A = 0
FOR I = 1 TO 5
A = A * 10 + I
PRINT A
NEXT I
END
Algorithm:
- Initialise a=0
- Iterate a loop in the range 1 to 5.
- Multiply the value of a by 10 and add the value of the loop variable to it.
- Display the value of a with a new line.
Refer to the attachment for output.
•••♪
Attachments:
Answered by
12
Answer:
There are 2 ways to write this...
Method 1: Using 2 loops
CLS
FOR I=1 TO 4
FOR J=1 TO I
PRINT J
NEXT J
NEXT I
END
Method 2: Using only 1 loop
CLS
A=1
FOR I=1 TO 4
PRINT A
A=A*10+I
END
Similar questions
Political Science,
1 month ago
English,
1 month ago
Math,
1 month ago
Math,
2 months ago
History,
9 months ago