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 |
how to sort two array of characters and make a new array of characters.
Write a C++ program without using any loop (if, for, while etc) to print prime numbers from 1 to 100 and 100 to 1 (Do not use 200 print statements!!!)
How to use c/c++ code in JAVA
10 Answers CDAC, IBM, Satyam, Scope International,
How do you determine the length of a string value that was stored in a variable?
Where is volatile variable stored?
How can you increase the allowable number of simultaneously open files?
How is a macro different from a function?
How can type-insensitive macros be created?
How to swap 3 numbers without using 4th variable?
What is the use of getchar() function?
What is the difference between void main and main in c?
What is the difference between malloc() and realloc()?