coding for Fibonacci.?

Answer Posted / siggi

class hcl
{
public static void main(String arg[])
{int a=0;
int b=1;
int i=1;
int x,y;

/*System.out.println("enter the no.");*/
x=Integer.parseInt(arg[0]);
if(x==0 || x==1)
{ System.out.println("yes it is");}

else {

do
{
y=a+b;
if(x==y)
{ System.out.println("yes it is");
i=0;}
else if(x>y)
{a=b;
b=y;}
else
{ i=0;
System.out.println("no it is not");}

}while(i!=0);

}
}
}

Is This Answer Correct ?    1 Yes 3 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is the sizeof () operator?

630


Explain is it better to bitshift a value than to multiply by 2?

724


Explain what is the difference between functions getch() and getche()?

616


What is header file in c?

611


What is a pointer and how it is initialized?

615






What is the difference between int main and void main in c?

601


What is the purpose of the preprocessor directive error?

693


Explain what is a 'null pointer assignment' error? Explain what are bus errors, memory faults, and core dumps?

652


Why does everyone say not to use scanf? What should I use instead?

687


What is the explanation for modular programming?

694


Why is c used in embedded systems?

621


What is switch in c?

656


What is anagram in c?

525


What is getch?

642


Can we use visual studio for c?

560