[go: up one dir, main page]

0% found this document useful (0 votes)
19 views1 page

Check Out These Related Examples:: Scanf ("%d",&broj) Fwaof Fwoajfčasfž Afsklaćfasuifa

The document appears to be code for a C program that calculates and prints the Fibonacci sequence up to a positive number entered by the user. It initializes three integers to track the previous two terms and calculate the next term, and uses a while loop to iteratively add the previous two terms and print the result until it exceeds the input number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
19 views1 page

Check Out These Related Examples:: Scanf ("%d",&broj) Fwaof Fwoajfčasfž Afsklaćfasuifa

The document appears to be code for a C program that calculates and prints the Fibonacci sequence up to a positive number entered by the user. It initializes three integers to track the previous two terms and calculate the next term, and uses a while loop to iteratively add the previous two terms and print the result until it exceeds the input number.
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 1

scanf("%d",&broj);fwaof

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,

Check out these related examples:


 Check Whether a Number is Positive or Negative
 Display Factors of a Number
 Check Whether a Number is Prime or Not
 Calculate the Power of a Number
 Count Number of Digits in an Integer
 Display Armstrong Number Between Two Intervals
 Check Whether a Number is Even or Odd
 Find the Largest Number Among Three Numbers

You might also like