Programming C, C++, Java, PHP, Ruby, Turing, VB
Computer Science Canada 
Programming C, C++, Java, PHP, Ruby, Turing, VB  

Username:   Password: 
 RegisterRegister   
 Simple Fibonacci Code
Index -> Programming, Turing -> Turing Submissions
View previous topic Printable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic
Author Message
Malazan




PostPosted: Thu Jun 09, 2005 10:16 am   Post subject: Simple Fibonacci Code

code:

var a, b, c : real %Variables
var term : int
put "Please enter how many terms you want in this sequence: " .. %Prompts user for how many terms wanted.
get term

var Fib : array 1 .. term of real %Starts an array
a := 1 %Declares a as 1
b := 0 %Declares b as 0
for i : 1 .. term %Makes the program so that it will display as many terms as the user wants
c:= a + b %The equation so that the first 2 numbers will add up to the next number
put c , " " .. %Outputs the number
a:= b %A is declared as B. A is now the next number.
b:= c %B is declared as C. B is now the next number. The sequence is able to progress.
end for 

Quite possibly the easiest to use Fibonacci code? 8) I didn't use any complicated stuff, and added a user prompt for how many terms the user wants Rolling Eyes
Sponsor
Sponsor
Sponsor
sponsor
strike_hawk89




PostPosted: Fri Jun 10, 2005 9:45 am   Post subject: (No subject)

hey nub, u dont need that "Fib" array.
Malazan




PostPosted: Fri Jun 10, 2005 10:11 am   Post subject: (No subject)

Oops Mad
MysticVegeta




PostPosted: Fri Jun 10, 2005 4:11 pm   Post subject: (No subject)

strike_hawk89 wrote:
nub,


thats quite offending.. please dont use it.
md




PostPosted: Fri Jun 10, 2005 6:29 pm   Post subject: (No subject)

strike_hawk89 wrote:
hey nub,...

I assume you meant "noob", but even then; you have what? like 20 posts? And most of those are you asking questions, either to get help, or to try and figure out others code... so I ask you; who is the real noob?

I have nothing against people who are new to programming, and I am more then happy to answer their questions whenever I am able. However to call someone a "noob" is deplorable; especially given that you are equally a "noob".

As for the Fibonacci code; looks good. The two things I must point out are yes, the Fib array isn't used, so you should remove it; and if there is one thing I can't stand it's comments that follow at the end of a line. Comments on the same line as code is a good thing, however, it's much easier to read your code if the comments are all lined up after your code. I like my code to look like a two column article in the paper, the left column is the code; the right the comments.

But aside from those two things (and the second is admitedly a personal preference) it tooks good!
Display posts from previous:   
   Index -> Programming, Turing -> Turing Submissions
View previous topic Tell A FriendPrintable versionDownload TopicRate TopicSubscribe to this topicPrivate MessagesRefresh page View next topic

Page 1 of 1  [ 5 Posts ]
Jump to:   


Style:  
Search: