Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- // C program to print fibonacci series upto n terms.
- #include <stdio.h>
- int main(){
- int x,FN=0,SN=1,temp, i;
- printf("Enter a number :");
- scanf("%d", &x);
- printf("First %d terms of Fibonacci series are:\n", x);
- for (i=0; i<x; i++){
- if (i<=1)
- temp=i;
- else{
- temp=FN+SN;
- FN=SN;
- SN=temp;}
- printf("%d\n",temp);
- }
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment