/*Program to Print Fibonacci terms*/
#include<stdio.h>
void main() {
int a, b, c, i, n;
printf("\nEnter the first two numbers: ");
scanf("%d %d", &a, &b);
printf("Enter the value of n: ");
scanf("%d", &n);
printf("\nThe %d Fibonacci terms are: ", n);
printf("%d, %d", a, b);
for (i = 2; i < n; i++) {
c = a + b;
a = b;
b = c;
printf(", %d", c);
}
}
WHAT'S NEW?
Loading...
0 comments:
Post a Comment