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 |
What are the phases in s/w developed life cycle? wat is the diff b/w stack & queue...where do we use stack
How can you invoke another program from within a C program?
What are local static variables?
What is the advantage of a random access file?
explain how do you use macro?
Go through the following code sinippet char a[20]; a="Hello Orcale Test"; will this compile?
How is = symbol different from == symbol in c programming?
Why c language?
Input any no. and print all the the numbers that comes before it like this for e.g input = 4 0 01 012 0123 01234 plz answer it 2day
What are pointers? Why are they used?
What is scope and lifetime of a variable in c?
How does free() know how many bytes to free?