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 is the diff b/w static and non static variables in C. Give some examples plz.
What is p in text message?
Explain how do you search data in a data file using random access method?
While(1) { } when this loop get terminate is it a infinite loop?
plz answer..... a program that reads non-negative integer and computes and prints its factorial
What is the difference between exit() and _exit() function in c?
Write a c pgm for leap year
11 Answers College School Exams Tests, IBM, TCS,
what will be the output of "printf("%d%d",scanf("%d% d",&a,&b))".provide an explation regarding the question
Why dont c comments nest?
which is the best antivirus and how to update it
What is signed and unsigned?
What is file in c preprocessor?