| | |
C++ Fibonacci program help
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
C++ Syntax (Toggle Plain Text)
#include <iostream.h> #include <stdlib.h> int fibonacci() { unsigned long fib; cout << "Please input a number of fibonacci numbers which will be displayed: "; cin >> fib; unsigned long a = 1; unsigned long b = 1; unsigned long temp; for (int count1 = 0; fib != count1; count1 ++) { cout << a << " is the " << count1 + 1 << "th number\n"; temp = b; b += a; a = temp; } return 0; } int main() { fibonacci(); cout << endl; system("PAUSE"); return 0; }
•
•
•
•
Wouldn't that trap high at 1 and low at 0? Perhaps 1, 1 are what you meant as starting vars.
high = 1 ; low = 0
------------------------
high = 1 ; low = 1
high = 2 ; low = 1
high = 3 ; low = 2
high = 5 ; low = 3
high = 8 ; low = 5
high = 13 ; low = 8
high = 21 ; low = 13
high = 34 ; low = 21
high = 55 ; low = 34
high = 89 ; low = 55 Last edited by invisal; Jan 1st, 2008 at 4:26 pm.
Yesterday is a history, tomorrow is a mystery, today is a gift.
Behind every smile is a tear.
Visal .In
Behind every smile is a tear.
Visal .In
![]() |
Similar Threads
- need an idea to program (Computer Science)
Other Threads in the C++ Forum
- Previous Thread: stack , queue and linked list
- Next Thread: Common problem solver framework design
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment beginner binary bitmap c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete developer dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator getline graph homeworkhelper iamthwee ifstream image input int integer java lib list loop looping loops map math matrix memory multidimensional multiple newbie news node number numbertoword output parameter pointer problem program programming project proxy python random read recursion recursive reference rpg sorting string strings struct template text tree url variable vector video visual visualstudio win32 windows winsock word wordfrequency wxwidgets







Next time, I will check the date. (mad)