Okay here's what I have... it's a start. My only problem is when I run the program the sequence does not print the first 1 in the 1, 1, 2, 3, 5, 8,... it will only print 1, 2, 3, 5, 8,...

I believe it has something to do with "final" on the end of my code... any ideas?

~Ty

#include "stdafx.h"
#include <iostream>

using namespace std;

int _tmain(int argc, _TCHAR* argv[]){

int initial = 0, secondary = 1, final, N, count = 10;
	cout << "Enter in amount of numbers for Fibonacci to calculate: ";
	cin >> N;

for(count = 1; count <= N; count++){

	final = initial + secondary; 

	cout << final << endl;

	initial = secondary;
	secondary = final;
}
	system("PAUSE");
	return 0;
}

Recommended Answers

All 3 Replies

wait I think I saw my problem...

... ummm nope that didn't work...

line 11 cout << secondary

commented: Thanks! +1

line 11 cout << secondary

Ah perfect... with the endl; at the end it works like it should thanks bud!

~Ty

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.