0 votes
117 views
in C programming by (98.9k points)
edited
C Program to Print Fibonacci Series

1 Answer

0 votes
by (98.9k points)
selected by
 
Best answer
#include <stdio.h>
#include <conio.h>
 
int main(){
    int terms, lastNumber=1,secondLast=0,currentNumber=0,counter;
    printf("Enter number of terms in Fibonacci series: ");
    scanf("%d", &terms);
   for(counter = 0; counter < terms; counter++){
        if(counter < 2){
            currentNumber = counter;
        } else {
            currentNumber = lastNumber + secondLast;
            secondLast = lastNumber;
            lastNumber = currentNumber;
        }
        printf("%d ", currentNumber);
    }
    getch();
    return 0;
}

 

Related questions

0 votes
1 answer 463 views
0 votes
1 answer 193 views
0 votes
1 answer 176 views
0 votes
1 answer 117 views
0 votes
1 answer 124 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)
0 votes
1 answer 113 views
asked Jul 20, 2022 in C programming by Doubtly (98.9k points)

Doubtly is an online community for engineering students, offering:

  • Free viva questions PDFs
  • Previous year question papers (PYQs)
  • Academic doubt solutions
  • Expert-guided solutions

Get the pro version for free by logging in!

5.7k questions

5.1k answers

108 comments

554 users

...