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

Where we use clrscr in c?

0 Answers  


What is a void pointer? When is a void pointer used?

0 Answers   Aspire, Infogain,


Difference between Shallow copy and Deep copy?

0 Answers  


What is an example of enumeration?

1 Answers  


which of the following go out of the loopo if expn 2 becoming false a.while(expn 1){...if(expn 2)continue;} b.while(!expn 1){if(expn 2)continue;...} c.do{..if(expn 1)continue;..}while(expn 2); d.while(!expn 2){if(expn 1)continue;..}

4 Answers   TCS,


What is main () in c?

0 Answers  


Are pointers integer?

0 Answers  


what is c?

13 Answers   Tech Mahindra,


How can I prevent other programmers from violating encapsulation by seeing the private parts of my class?

1 Answers  


why in C,C++'s int size is 2 byte and .net(c#) int Size is 4 byte?

2 Answers  


Is multithreading possible in c?

0 Answers  


What are the types of pointers?

0 Answers  


Categories