![]() |
China DOS Union-- Unite DOS · Advance DOS · Grow DOS --Union site: www.cn-dos.net Forum site: www.cn-dos.net/forum |
| Guest | Log in | Register | Members | Search | China DOS Union |
|
中国DOS联盟论坛 The time now is 2026-09-14 23:50 |
47,812 topics / 349,917 posts / today 0 new / 48,268 members |
| DOS开发编程 & 发展交流 (开发室) » Question about a QB program |
| Printable Version 1,537 / 7 |
| Floor1 jo | Posted 2002-11-22 00:00 |
| 初级用户 Posts 22 Credits 172 | |
|
Can I ask questions about QB?
|
|
| Floor2 MYS | Posted 2002-11-22 00:00 |
| 元老会员 Posts 1,637 Credits 5,170 From 广东佛山 | |
|
Yes, it's QBASIC, right.
|
|
| Floor3 jo | Posted 2002-11-22 00:00 |
| 初级用户 Posts 22 Credits 172 | |
|
Here's a question: “2/1,3/2,5/3,5/8,13/8,21/13.... find the sum of the first 20 terms of this sequence” How should this be coded?
cls a=1:b=1:m=0 for i= 1 to 20 a=a+b m=m+a/b b=a next i print m The output is 40. Where is the mistake? |
|
| Floor4 MYS | Posted 2002-11-22 00:00 |
| 元老会员 Posts 1,637 Credits 5,170 From 广东佛山 | |
|
Your program is wrong. I worked it out, and when i=1, the formula is correct,
a=a+b=2 ;m=m+2/1 But when i=2 it's no longer right. Because earlier b=a, so b=2; at this time this term's a+b=4, m=m+4/2. Work it out and see |
|
| Floor5 MYS | Posted 2002-11-22 00:00 |
| 元老会员 Posts 1,637 Credits 5,170 From 广东佛山 | |
|
Try coding it like this:
cls a=2:b=1:m=0 for i= 1 to 20 m=m+a/b t=a+b b=a a=t next i print m |
|
| Floor6 jo | Posted 2002-11-22 00:00 |
| 初级用户 Posts 22 Credits 172 | |
|
Could I trouble you to write out the correct one? I've been thinking about it for a long time already~ boohoohoo
|
|
| Floor7 MYS | Posted 2002-11-23 00:00 |
| 元老会员 Posts 1,637 Credits 5,170 From 广东佛山 | |
|
Isn't the program I gave already the correct one?
|
|
| Floor8 jo | Posted 2002-11-23 00:00 |
| 初级用户 Posts 22 Credits 172 | |
|
Thank you so, so much~
|
|
|
[ Contact the Union admin team -
中国DOS联盟 -
Standard version ] Sponsored by ifanr Inc | © 2001–2023 |