Home › Tutorials & Guides › Coding Tutorials › C++ Program to generate Fibonacci Triangle

C++ Program to generate Fibonacci Triangle

This article shows that C++ Program to generate Fibonacci Triangle. In this program, we are getting input from the user for the limit for FibonacciĀ series triangle, and printing the Fibonacci series for the given number of times (limit).

Char array to string in C++.

Let’s see the C++ program to generate Fibonacci series triangle.

#include <iostream>  
using namespace std;  
int main()  
{  
  int a=0,b=1,i,c,n,j;    
    cout<<"Enter the limit: ";    
    cin>>n;    
    for(i=1; i<=n; i++)    
    {    
        a=0;    
        b=1;    
        cout<<b<<"\t";   
        for(j=1; j<i; j++)    
        {    
            c=a+b;    
          cout<<c<<"\t";    
            a=b;    
            b=c;  
        }    
        cout<<"\n";    
    }    
return 0;  
}  

Output:

Enter the limit: 6 
1   
1       1   
1       1       2   
1       1       2       3    
1       1       2       3       5   
1       1       2       3       5       8
Note: If you interested lo learn C++ through web, You can click here

Conclusion:

Hi guys, I can hope that you can know that how to write a C++ Program to generate Fibonacci Triangle. If you like this post as well as know something new so share this article in your social media accounts. If you have any doubt related to this post then you ask in comment section.

Similar Posts

Leave a Reply

Your email address will not be published. Required fields are marked *