Is my code good enough to get me an A or a B?
Produces incorrect output
After a while the code produces wrong output. I would not mind so much that code has a limited range, but one that starts producing errors, without warning, is not good. B for effort - I admire your goals, C for implementation.
FP for an integer problem
The Fibonacci series runs though various odd numbers, resulting in incorrect results after the precision of double
is used up at about 2DBL_MANT_DIG or typically 253. unsigned long long
affords at least 264-1.
Although using double
allows for a greater range, I'd see using floating point (FP) as a weaker approach to this problem than integers and strings.
Unneeded code
Sleep(2500);
no functional purpose to the calculation of the Fibonacci series. Use of magic numbers 2500, 250 lacks explanation.
main() lacks return type
This style of programming went out 20 years ago. Code the return type.
// main(){
int main() {
// or clearly
int main(void) {
Consider declaring object when/where needed
Example
//double x, y, xy;
//...
//while (1){
// xy = x + y;
double x = 0;
double y = 1;
...
while (1) {
double xy = x + y;
Strange to use end-of-line to start printing
A more common idiom is '\n'
afterwards and facilitates flushing stdout
when line buffered.
//printf("\n%.0lf", y);
printf("%.0lf\n", y);
Minor: odd formatting
}}
is uncommon. Perhaps:
}
}
Can I make the code more professional?
Stop before the algorithm can no longer provide correct output.