write a program for fibonaci series by using while loop in c?
Answers were Sorted based on User's Feedback
Answer / rajendra raji
main()
{
int a=0,b=1,c,n;
printf("enter n value");
scanf("%d",&n);
Printf("%d%d",a,b);
n=n-2;
while(n>0)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
n--;
}
}
Explanation:
Hi....
if you give n value as 5, then it will print 5 values including the first printed a and b values..!!
try it once.. it will definitely work..
Is This Answer Correct ? | 2 Yes | 0 No |
Answer / shamantha
main()
{
int a=0,b=1,c,n;
printf("enter n value");
scanf("%d",&n);
Printf("%d%d",a,b);
while(n-2>0)
{
c=a+b;
printf("%d",c);
a=b;
b=c;
n=n+1;
}
}
Is This Answer Correct ? | 1 Yes | 2 No |
how to set Nth bit of a variable?
hat is a pointer?
how to determine the complexity of an algorithm as log(n)
Three major criteria of scheduling.
what is meant by the "equivalence of pointers and arrays" in C?
Explain what is wrong with this program statement?
what is an array
Some coders debug their programs by placing comment symbols on some codes instead of deleting it. How does this aid in debugging?
What are the Advantages of using macro
c programs are converted into machine language with the help of a) an interpreter b) a compiler c) an operatinf system d) none of the above
what is c
What is hashing in c?