Can you tell me how it is possible to use a loop to make several time the same calculation:exemple
Y=SIN(A)
with A= 2,3,4,5 etc
something like
FOR N=1 TO 10
PRINT Y=SIN(N)
NEXT N
Many thanks in advance
Repeating same calculations with incremental variable
- burger2227
- Veteran
- Posts: 2466
- Joined: Mon Aug 21, 2006 12:40 am
- Location: Pittsburgh, PA
You cannot PRINT a variable definition, but you get no error either!
Your code:
FOR N = 1 TO 10
PRINT Y = SIN(N)
NEXT N
Print the variable value:
FOR N = 1 TO 10
Y = SIN(N)
PRINT Y
NEXT N
OR just print the function return:
FOR N = 1 TO 10
PRINT SIN(N)
NEXT N
SIN and COS use radian values up to 2 * PI = 6.28. Going above that creates negative values.
Your code:
FOR N = 1 TO 10
PRINT Y = SIN(N)
NEXT N
Print the variable value:
FOR N = 1 TO 10
Y = SIN(N)
PRINT Y
NEXT N
OR just print the function return:
FOR N = 1 TO 10
PRINT SIN(N)
NEXT N
SIN and COS use radian values up to 2 * PI = 6.28. Going above that creates negative values.
Please acknowledge and thank members who answer your questions!
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
QB64 is a FREE QBasic compiler for WIN, MAC(OSX) and LINUX : https://www.qb64.org/forum/index.php
Get my Q-Basics demonstrator: https://www.dropbox.com/s/fdmgp91d6h8ps ... s.zip?dl=0
formula with incremental values
THANKS A LOT!