c how to fibonacci

Solutions on MaxInterview for c how to fibonacci by the best coders in the world

showing results for - "c how to fibonacci"
Hope
30 Apr 2020
1#include <stdio.h>
2#include <stdlib.h>
3
4int main() {
5	long int a = 1,b = 2, c, d, cont = 0;
6	double e, f;
7	
8	printf("Fibonacci fino a: ");
9	scanf("%ld", &c);
10	
11	while(b < c)
12	{
13		cont ++;
14		printf("\n%ld", b);
15		d = a;
16		a = b;
17		b = b + d;
18	}
19	
20	f = (double)b / (double)a;
21	
22	e = (double)cont / (double)c * (double)100;
23	
24	printf("\n\nOttenuto: %lf\nPercentuale: %lf\n\n\n", f, e);
25	
26	system("pause");
27}