Professional Documents
Culture Documents
Check Out These Related Examples:: Scanf ("%d",&broj) Fwaof Fwoajfčasfž Afsklaćfasuifa
Check Out These Related Examples:: Scanf ("%d",&broj) Fwaof Fwoajfčasfž Afsklaćfasuifa
Check Out These Related Examples:: Scanf ("%d",&broj) Fwaof Fwoajfčasfž Afsklaćfasuifa
fwoajfčasfž
afsklaćfasuifa
1. fajkfčlafsćč#include <stdio.h>
2. int main()
3. {
4. int t1 = 0, t2 = 1, nextTerm = 0, n;
5.
6. printf("Enter a positive number: ");
7. scanf("%d", &n);
8.
9. // displays the first two terms which is always 0 and 1
10. printf("Fibonacci Series: %d, %d, ", t1, t2);
11.
12. nextTerm = t1 + t2;
13.
14. while(nextTerm <= n)
15. {
16. printf("%d, ",nextTerm);
17. t1 = t2;
18. t2 = nextTerm;
19. nextTerm = t1 + t2;
20. }
21.
22. return 0;
23. }
Output
Enter a positive integer: 100
Fibonacci Series: 0, 1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89,