- The Fibonacci series shall never yield non whole numbers;
double
s are unnecessary and possibly computationally expensive. Try auintmax_t
. It will probably give you values of up to 2^64 - 1 (18,446,744,073,709,551,615). That should certainly be sufficient. Additionally, I would put in code to terminate the program as it reaches the upper limit ofuintmax_t
. - Your could have a classic I/O problem: output buffering. Try to put a
\n
in every print statement to encourage proper flushing. So rather than having the come at the beginning of each print statement, try putting it at the end. If you like it the way it is, you can callfflush(stdout)
after everyprintf()
. While we're on the topic, your first twoprintf()
statements can be combined. More info at this SO question. - Obviously the
Sleep()
functions are unnecessary to your code. I presume that they are there for the aesthetic value of the output, but I would take them out. Doing so would make your code OS-independent as well as neater. But obviously, depending on the assignment, appearance may be above all. - Finally, despite the mathematical purpose of the program,
math.h
is not needed.
Addendum: You asked how to make it more professional. You could make a Fibonacci function returning always the next value based on static/global variable(s). You could then put the prettiness of sleeping and the welcome message in main()
while maintaining the purity of your algorithm.