coding for Fibonacci.?



coding for Fibonacci.? ..

Answer / 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

More C Interview Questions

c program to subtract between two numbers without using '-' sign and subtract function.

2 Answers  


What is I ++ in c programming?

0 Answers  


what is answer for perfect number????????????????

1 Answers  


write c program to display output 10(10+20)+(10+20+30)+ ... n term

0 Answers   Hindustan Gum Chemicals,


Why c++ is called c++ and not c+?

9 Answers   EBS,


Why do some versions of toupper act strangely if given an upper-case letter?

0 Answers  


What does nil mean in c?

0 Answers  


What are c identifiers?

0 Answers  


mplementation of stack using any programing language

1 Answers   Marlabs,


Describe explain how arrays can be passed to a user defined function

0 Answers  


Difference between malloc() and calloc() function?

0 Answers  


How to explain the final year project as a fresher please answer with sample project

0 Answers  


Categories