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
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; }
Step by Step Solution
There are 3 Steps involved in it
Step: 1
Get Instant Access to Expert-Tailored Solutions
See step-by-step solutions with expert insights and AI powered tools for academic success
Step: 2
Step: 3
Ace Your Homework with AI
Get the answers you need in no time with our AI-driven, step-by-step assistance
Get Started