a. Write a QBasic program to generate the following series: 1, 4, 9, 16, 25

b. Write a QBasic program to generate the following series: 5, 25, 125, 625, 3125

Answer :

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.