I'm new to c++ programming! I need some help writing a program that generates then prints out the terms of the fibonacci sequence. Any suggestions?
I'm new to c++ programming! I need some help writing a program that generates then prints out the terms of the fibonacci sequence. Any suggestions?
Tech youreslff C++ in 21 days have a couple of differnt solutions.
http://firstpod.tripod.com/cpp21/
~Barjor
Any number in the Fibonacci Sequence is equal to the sum of the two previous numbers. You start with 0 and 1.
I'm SURE you can figure it out from there!!!Code:0 = 0 1 = 1 0 + 1 = 1 1 + 1 = 2 1 + 2 = 3 3 + 2 = 5 5 + 3 = 8 8 + 5 = 13 etc...
Try a recursive function, that's how it's done in the Deitel textbook. The numbers get large pretty quickly, though.
try this (easier said than done):
a[n] += a[n-1] + a[n-2]
-Save the whales. Collect the whole set.
Try this code:
#include <stdio.h>
void main(void)
{
char get_key;
int x = 1;
int y;
int z;
/* just make a loop for the rest of the code to limit how high it counts in fibonacci numbers. A for( ; ; loop may be best. */
printf("%f", x);
z = x + y;
x = z;
Sorry, pressed the send key accidentally. Just make the following changes to the code:
After you have the printf statement, add, "y = x" on the next line. At the end, add, "getch(get_key);", and on the final line, "}".
That should, work, but double check some of variable assignements and math.