Question: Linux and C. I already have a code for the first one but not the Overflow cases. The code is below Code I have: Like

Linux and C. I already have a code for the first one but not the Overflow cases. The code is below

Linux and C. I already have a code for the first onebut not the Overflow cases. The code is below Code I have:

Code I have: Like I said everything is working but not the overflow case.

#include

int fibo_negative(int N) /*this function compute for negative N*/

{

int past = 1,i; /*past variable contain number which is 2 step beyond */

int present = 0; /*present variable contain number which is 1 step beyond */

int next; /*next variable compute the present number that we are interested in*/

for(i=0;i

{

next = past-present;

past = present;

present = next;

}

return next;

}

int fibo_positive(int N) /*this function compute for positive N*/

{

int past = 0,i; //past variable contain number which is 2 step beyond

int present = 1; //present variable contain number which is 1 step beyond

int next; /ext variable compute the present number that we are interested in

for(i=0;i

{

next = past+present;

past = present;

present = next;

}

return next;

}

int main()

{

int N;

printf(" Enter a number:"); //Prompt the user

scanf("%d",&N);

if(N

printf("F(%d) is %d ",N,fibo_negative(N)); /*If N is negative then call fibo_negative */

else

printf("F(%d) is %d ",N,fibo_positive(N)); /*If N is positive then call fibo_positive */

return 0;

}

2. Define the extended Fibonacci numbers, F as follows: Fn = Fn-l + Fn-2 if n > 1 F-Fn+2-Fn+ if n

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!