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 does c mean in basketball?
Is double link list a linear data structure? If Yes, Why?If No, Why?
What is the difference between printf and scanf in c?
main() { int i = 10; printf(" %d %d %d \n", ++i, i++, ++i); }
How to removing white spces in c programming only bu using loops
How do you generate random numbers in C?
Write a simple code fragment that will check if a number is positive or negative.
which one is highest Priority in c? a)=,b)+,c)++,d)==
Determine the code below, tell me exactly how many times is the operation sum++ performed ? for ( i = 0; i < 100; i++ ) for ( j = 100; j > 100 - i; j--) sum++;
Given an array of numbers, except for one number all the others occur twice. Give an algorithm to find that number which occurs only once in the array.
int main() { int *p=new int; *p=10; del p; cout<<*p; *p= 60; cout<<*p; } what will be the output & why?
What is the use of structure padding in c?