CodesJava

Easy learning with example program codes

C program to print Fibonacci Triangle


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
Posted in C   
Sign Up/ Sign In
Ask a Question


Industrial Training

We offers Placement Oriented Training on Java, Spring, JSF, Hibernate, PHP, AngularJS, Angular 4, PLSQL, Oracle BI Publisher etc. We also provides Online training, please mail us at hr@codesjava.com.

Development

We also provides the Development services for Website Development , Java Development, PHP Development, Android App Development etc. You can contact us on hr@codesjava.com.

Copyright © 2018 CodesJava DMCA.com Protection Status SiteMap Reference: Java Wiki