// Fibonacci Series in C Programming
#include<stdio.h>
int main(){
int n,i, a = 0, b = 1, fib;
printf("Enter the number of terms:");
scanf("%d",&n);
printf("First %d Number of Fibonacci series are :\t",n);
for ( i = 0 ; i < n ; i++ ){
if ( i <= 1 )
fib = i;
else{
fib = a + b;
a = b;
b = fib;
}
printf("%d\t",fib);
}
return 0;
}
Output
#include<stdio.h>
int main(){
int n,i, a = 0, b = 1, fib;
printf("Enter the number of terms:");
scanf("%d",&n);
printf("First %d Number of Fibonacci series are :\t",n);
for ( i = 0 ; i < n ; i++ ){
if ( i <= 1 )
fib = i;
else{
fib = a + b;
a = b;
b = fib;
}
printf("%d\t",fib);
}
return 0;
}
Output
কোন মন্তব্য নেই:
একটি মন্তব্য পোস্ট করুন