This program I have written has the user enter a number and it will display the fibonacci number that is associated with that number. This part works what i need to know what do I need in my code so that a user can enter 0 or a negative number so they can quit. I want it so that it will ask the user to enter a number and give the fibonacci number until a user enters a 0 or a negative number then it will end the program.
Thanks,
Nate
#include <iostream.h>
#include <math.h>
#include <iomanip.h>
int main()
{
int count = 0;
int count2 = 1;
int count3 = 1;
int count4 = 0;
int num;
cout << "Enter a number (0 or a negative to quit): ";
cin >> num;
do
{
count3 = count + count2;
count2 = count;
count = count3;
count4 += 1;
}while ( count4 != num );
cout << "Fibonacci ( " << num << " ) = " << count3 << endl;
return 0;
}