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

writw a program to insert an element in the begning of a doubly linked list

1 Answers  


How can I prevent another program from modifying part of a file that I am modifying?

0 Answers  


What is the scope of static variables?

1 Answers  


What does c mean before a date?

0 Answers  


In the below code, how do you modify the value 'a' and print in the function. You'll be allowed to add code only inside the called function. main() { int a=5; function(); // no parameters should be passed } function() { /* add code here to modify the value of and print here */ }

1 Answers  






How can I get back to the interactive keyboard if stdin is redirected?

0 Answers  


being a chemical engineer and with an aggregate of 80% why you opt for TCS and not your core industry?

1 Answers   TCS,


advantages of pointers?

3 Answers  


Why do we use pointer to pointer in c?

0 Answers  


do ne body have any idea about the salary for the we r going to have interview. yup .. u got it right ..i m talking abt NIC.

1 Answers  


Is swift based on c?

0 Answers  


What is an object?

5 Answers  


Categories