**What is Tribonacci Series?**

Tribonacci Series is the Successor of Fibonacci Series in which each element is the sum of the previous three consecutive elements.

Note:The first three elements of the Tribonacci Series will be always 0, 1 and 2.

The first three elements of the tribonacci series remain independent as from the fourth element the rule for tribonacci series is applied.

**Example of Tribonacci Series**

0 1 2 3 6 11 20 37

Let we consider the number 20 from the above series, now if we add it's previous three element 3+6+11 we get the answer 20.

Now let's create a C program to print Tribonacci Series up to n elements where n will be taken from the user.

**C program for Tribonacci Series**

```
#include<stdio.h>
int main(){
int n,i;
int a=0,b=1,c=2,d;
printf("Enter a number\n");
scanf("%d",&n);
printf("%d %d %d ",a,b,c);
for(i=0;i<n-3;i++){
d = a + b + c;
printf("%d ",d);
a = b;
b = c;
c = d;
}
}
```

**C++ program for Tribonacci Series**

```
#include<iostream>
using namespace std;
int main(){
int n,i;
int a=0,b=1,c=2,d;
cout<<"Enter a number\n";
cin>>n;
cout<<a<<" "<<b<<" "<<c<<" ";
for(i=0;i<n-3;i++){
d = a + b + c;
cout<<d<<" ";
a = b;
b = c;
c = d;
}
return 0;
}
```

**Output of the above programs**

Thank you for reading.

Tweet your queries and feedback to @PsychoCodes or leave a message on our Facebook page. You can also comment your questions below.

Also, don't forget to subscribe to our Newsletter.

If you like this article, then please share it and help us grow.

Preorder and Postorder Traversal of binary tree in Python

02 September 2018

Binary Tree in Python

02 September 2018

Image Sharpening by High Pass Filter using Python and OpenCV

17 August 2018

Explaining Register variables in C with examples

17 August 2018

C program to generate all combinations of N-Bit Binary String

10 July 2018

Data Autosave System using PHP, MySQL and AJAX

06 July 2018

3DAJAXAlgorithmsC programmingC ProgramsC TutorialsC-plusplusCMSComputer ScienceCSSData StructuresDjangoHackingHTMLInformation SecurityInterview QuestionsJavaJava ProgramsJava TutorialsJavascriptJavaScript TutorialsJSONOpenCVPHPProgrammingProgramming BooksPythonPython ProgramsSQLSteganographyTechnologyWeb DesigningWeb Development

## Share your thoughts