Write a QBASIC Program:
a)To generate following numbers: 2 , 4, 6, 8 to 50
Answers
Answered by
1
Solution:
The given problem is solved in QBASIC.
CLS
FOR I = 2 TO 50 STEP 2
PRINT I;
NEXT I
END
Explanation:
- Line 1: Clears the screen.
- Line 2: A for loop is created to generate numbers. We have to display even numbers from 2 to 50. So, we write I = 2 to 50 so that the loop goes from 2 to 50. Step value is given 2 since even numbers lies at interval of 2 numbers.
- Line 3: The number is displayed on the screen.
- Line 4: End of loop.
- Line 5: End of program.
Refer to the attachment for output.
Attachments:
Similar questions