write a program for fibonaci series by using while loop in c?
Answer Posted / 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 |
Post New Answer View All Answers
What are the 5 types of inheritance in c ++?
What are pointers? What are stacks and queues?
What is function and its example?
Why do we use int main?
Why doesnt this code work?
how many key words availabel in c a) 28 b) 31 c) 32
What are register variables in c?
Should I learn data structures in c or python?
What is the explanation for cyclic nature of data types in c?
Study the following C program :call_me (myvar)int myvar;{ myvar +- 5; }main(){int myvar;myvar = 3;call_me(myvar);printf("%d ",myvar);What will be printed a) 3 b) 5 c) 8 d) symbol
Explain what is the benefit of using an enum rather than a #define constant?
Explain a file operation in C with an example.
Is main is a keyword in c?
Why header file is used in c?
What is c language in simple words?