The below program is to print the Fibonacci Triangle in C using loop.
C program to print Fibonacci Triangle
#include <stdio.h> #include<stdlib.h> void main() { int i,j,k,m; int a= 0, b=2; for(i=1; i<=5; i++) { printf("%d\t",b); for(k=1; k<i; k++) { m=a+b; printf("%d\t",m); a=b; b=m; } printf("\n"); } } |
Output
2 2 2 2 4 6 6 10 16 26 26 42 68 110 178 |