Chat with our AI personalities
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.
For N = 1 to 10 Print 2 * N Next N
The best way to print the numbers 1 to 100 in PHP without using a loop is with the following code: echo implode("<br>", range(1,100)); You can replace the <br> with anything that you want to separate the numbers, such as dashes. I used a line-break in the example.
#include<stdio.h> int main () { printf ("2 4 6 8 10 12 14 16 18 20"); return 0; }
DIM nums(10) CLS FOR i = 0 TO 9 nums(i) = (RND * 10) + 1 PRINT nums(i) NEXT PRINT : PRINT "Press Enter to sort numbers" rem pause to look at numbers DO WHILE INKEY$ = "": LOOP CLS FOR loop1 = 0 TO 9 FOR loop2 = loop1 + 1 TO 9 IF nums(loop1) > nums(loop2) THEN SWAP nums(loop1), nums(loop2) NEXT NEXT FOR i = 0 TO 9: PRINT nums(i): NEXT