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


Please Help Members By Posting Answers For Below Questions

In this problem you are to write a program that will cut some number of prime numbers from the list of prime numbers between 1 and N.Your program will read in a number N; determine the list of prime numbers between 1 and N; and print the C*2 prime numbers from the center of the list if there are an even number of prime numbers or (C*2)-1 prime numbers from the center of the list if there are an odd number of prime numbers in the list.

1474


How do I swap bytes?

723


What are keywords c?

696


How can a program be made to print the name of a source file where an error occurs?

840


What are the advantage of c language?

644






Write a program to print all permutations of a given string.

766


What is cohesion in c?

647


What are the 32 keywords in c?

747


Who invented bcpl language?

810


Write a C program to accept a matrix of any size. Find the frequency count of each element in the matrix and positions in which they appear in the matrix

1623


Explain what are linked list?

716


What is a stream in c programming?

694


What is array of structure in c programming?

859


c language supports bitwise operations, why a) 'c' language is system oriented b) 'c' language is problem oriented c) 'c' language is middle level language d) all the above

702


What is a char c?

693