127k views
5 votes
A. Write a qbasic program to generate the following series: 1, 4, 9, 16, 25

b. 5, 25, 125, 625, 3125
(urgent need for project work.)​

1 Answer

4 votes

Here's a QBasic program to generate the series:

Series of squares:

css

Copy code

FOR i = 1 TO 5

PRINT i * i;

NEXT i

Output: 1 4 9 16 25

Series of powers of 5:

css

Copy code

x = 5

FOR i = 1 TO 5

PRINT x;

x = x * 5

NEXT i

Output: 5 25 125 625 3125

In the first program, we use a loop to iterate through the values 1 to 5, and for each value of i, we calculate its square and print it to the console.

In the second program, we set the variable x to 5, and then use a loop to iterate through the values 1 to 5. For each value of i, we print the current value of x, and then update x by multiplying it by 5. This gives us a sequence of powers of 5.

User PublicRavi
by
8.8k points