#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;
}1 answer
Best answer
Was this answer helpful?
Thanks for the feedback.
Sign up free to save answers and ask your own doubts
Your answer
Log in or create a free account to answer this question.