Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

please use this code to anwser the question: #include #define FLUSH stdin = freopen ( NULL , r , stdin ) / /

please use this code to anwser the question:
#include
#define FLUSH stdin=freopen(NULL,"r",stdin)
// Prototype for Recursive function Tn()
// You must remove this prototype before you submit your assignment
unsigned long Tn(int);
// This function must collect the n to print T_n number in Tribonacci sequence.
int get_n();
// In this function, you must create an array of series.
// You must fill the array with the Fibonacci numbers.
// This function returns the HEAP address of such array
// Parameter: n you get from the get_n() function.
// Note: this function must create array of size n+1(!)
// Must detect integer overflow and adjust parameter n to the maximum allowed.
unsigned long* tribonacci_array(int*);
// This function prints T_n Tribonacci number.
// Accepts n value you get from get_n() function.
//(Note: pointer is used so you can modify value n in case of integer overflow!)
// Note: inside this function must call tribonacci_array() function above!
void print_Tn(int*);
// Define MIN_NUMBER and MAX_NUMBER symbolic constants that you d use to limit the input of size:
// This is starting point. See below how main() function should look like in your solution!
int main(){
int n =20;
printf("This program calculated Tribonacci number T_n,
");
printf("T_n=T_(n-3)+T_(n-2)+T_(n-1), where T_0=T_1=0 and T_2=1
");
printf("Tribonacci Number T_%d =%lu
", n, Tn(n));
return 0;
}
/* Your main() function must look like this:
int main(){
printf("This program calculated Tribonacci number T_n,
");
printf("T_n=T_(n-3)+T_(n-2)+T_(n-1), where T_0=T_1=0 and T_2=1
");
// Get value n
int n = get_n();
// Print value T_n
print_Tn(&n);
return 0;
}
*/
// You must remove this function before you submit your assignment
// Tribonacci numbers (start from n=0): 0,0,1,1,2,4,7,13,24,44,81,149,274
unsigned long Tn(int n){
if (n 2) return 0;
if (n ==2) return 1;
return Tn(n-1)+ Tn(n -2)+ Tn(n-3);
}
// You need to create this function.
// See comments for the prototype!
int get_n(){
}
// You need to create this function.
// See comments for the prototype!
unsigned long* tribonacci_array(int* n){
// Note: size of array should be n+1(!). So that T_5== array[5]!
}
// You need to create this function.
// See comments for the prototype!
void print_Tn(int* n){
}
image text in transcribed

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Pro SQL Server Administration

Authors: Peter Carter

1st Edition

1484207106, 9781484207109

More Books

Students also viewed these Databases questions