#include<stdio.h>
#include<conio.h>
main()
{
int a=0,b=1,c,i,n;
clrscr();
printf("enter the limit of series\n");
scanf("%d",&n);
if(n==0)
printf("%d\n",a);
else
printf("%d\n%d\n",a,b);
for(i=2;i<=n;i++)
{
c=a+b;
printf("%d\n",c);
a=b;
b=c;
}
getch();
}
You can write a C++ fib pro using arrays but the problem is the prog becomes very complicated since u need to pass the next adding value in an array.....
A compiler produces object code, which is an obj file.
#include<stdio.h> void printFibonacci(int); int main(){ int k,n; long int i=0,j=1,f; printf("Enter the range of the Fibonacci series: "); scanf("%d",&n); printf("Fibonacci Series: "); printf("%d %d ",0,1); printFibonacci(n); return 0; } void printFibonacci(int n){ static long int first=0,second=1,sum; if(n>0){ sum = first + second; first = second; second = sum; printf("%ld ",sum); printFibonacci(n-1); } }
The A Plus Program is an initiative, not a test. So no, there is no answer book.
#include<iostream> int main() { int x=0, y=1; std::cout<<x<<" "; std::cout<<y<<" "; while( y<1000000 ) { std::cout<<(y+=x)<<" "; x=y-x; } std::cout<<std::endl; return(0); }
i dn't know. haha
#include #include void main() { clrscr() int a=0,b=1,c,i,n; coutn cout
Yes, this can be done. For example for Fibonacci series. You will find plenty of examples if you google for the types of series you need to be generated.
That's the beginning of the Fibonacci series.
It's Fibonacci's
#include<iostream> int main() { int x=0, y=1; std::cout<<x<<" "; std::cout<<y<<" "; while( y<1000000 ) { std::cout<<(y+=x)<<" "; x=y-x; } std::cout<<std::endl; return(0); }
#include<iostream> unsigned fib (unsigned term, unsigned a=0, unsigned b=1) { if (term<1) return a; return fib (--term, a+b, a); } int main() { std::cout << "Fibonacci (1000th term): " << fib (1000) << std::endl; }
The roots are -1/2 of [ 1 plus or minus sqrt(5) ] . When rounded: 0.61803 and -1.61803. Their absolute values are the limits of the Fibonacci series, or the so-called 'Golden Ratio'.
You can write a C++ fib pro using arrays but the problem is the prog becomes very complicated since u need to pass the next adding value in an array.....
(xn+2-1)/(x2-1)
10 print "That is not a question." 20 print "That is a command." 30 end
A compiler produces object code, which is an obj file.