Chat with our AI personalities
You use the relevant formula.
In QBasic, you can print even numbers using a simple loop. For example, you can use a FOR loop to iterate through a range of numbers and then check if each number is even by using the modulus operator (MOD). Here's a sample code snippet: FOR i = 1 TO 20 IF i MOD 2 = 0 THEN PRINT i NEXT i This code will print all even numbers from 1 to 20.
CLS FOR eachNum%=1 TO 10 STEP 2 PRINT eachNum% NEXT
-- Think of a name for the sum, like 'S'.-- Tell qbasic what 'S' is the sum of.S = 41 + 61 + 2 + 84 + 136-- If you want to see it on the screen, thenPRINT Sand the sum pops up. It looks like this on the screen:324
divide the two numbers then divide