// for a given input print sum of its previous three terms
#include<stdio.h>
int sum(int a);
int main(){
int n;
scanf("%d",&n);
printf("n : %d\n",n);
sum(n);
return 0;
}
int sum(int a){
int e[a];
scanf("%d\n",&e[0]);
scanf("%d\n",&e[1]);
scanf("%d\n",&e[2]);
printf("e[0]=%d, e[1]=%d, e[2]=%d \n",e[0],e[1],e[2]);
for(int i=3;i<(a+1);i++){
e[i]=e[i-1]+e[i-2]+e[i-3];
}
printf("%d",e[a-1]);
// //Printing the entire array
// int l=sizeof(e)/sizeof(e[0]);
// for(int i=0;i<l;i++){
// printf("\n%d",e[i]);
// }
}
To embed this project on your website, copy the following code and paste it into your website's HTML: