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 is class and object in c?
Why shouldn’t I start variable names with underscores?
What is the data segment that is followed by c?
Why does this code crash?
What is 02d in c?
What are the valid places to have keyword “break”?
What is the difference between the = symbol and == symbol?
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
List out few of the applications that make use of Multilinked Structures?
What is function definition in c?
Write a function which takes as parameters one regular expression(only ? and * are the special characters) and a string and returns whether the string matched the regular expression.
.main() { char *p = "hello world!"; p[0] = 'H'; printf("%s",p); }
What is array in c with example?
What is a structure in c language. how to initialise a structure in c?
write a c program to do the following: a) To find the area of a triangle. b) To convert the temperature from Fahrenheit to Celsius. c) To convert the time in hours : minutes : seconds to seconds.