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 most efficient way to store flag values?
What is difference between function overloading and operator overloading?
When a c file is executed there are many files that are automatically opened what are they files?
why the execution starts from main function
Find string palindrome 10marks
5 Answers Honeywell, Infosys, Riktam, Roland,
A routine usually part of the operation system that loads a program into memory prior to execution a) linker b) loader c) preprocessor d) compiler
What is dynamic variable in c?
print out put like this form 1 2 3 4 5 6 3 5 7 9 11 8 12 16 20
1 1 1 1 2 1 1 3 3 1 1 4 6 4 1
how to execute with out main in cprogram
what is difference between ++(*p) and (*p)++
17 Answers Accenture, HCL, IBM,
What does main () mean in c?