#include
#include
main()
{
int n,i,c,a=0,b=1;
printf("Enter Fibonacci series of nth term : ");
scanf("%d",&n);
printf("%d %d ",a,b);
for(i=0;i<=(n-3);i++)
{
c=a+b;
a=b;
b=c;
printf("%d ",c);
}
getch();
}
Output :
Enter Fibonacci series of nth term : 7
0 1 1 2 3 5 8
Answer 2:/************************************************************************* Fibonacci In a Fibonacci series each number is the sum of the two previous numbers. This program calculates Fibonacci numbers within an 8-bit range, ;************************************************************************/#include < p18f452.h >
//these memory locations hold the Fibonacci series
unsigned char fib0; //lowest number
//(oldest when going up, newest when reversing down)
unsigned int fib1; //middle number
unsigned float fib2; //highest number
unsigned double fibtemp; //temporary location for newest number
main ()
{
counter 3; //have preloaded the first three numbers, so start at 3
fib0 0;
fib1 1;
fib2 1;
loop: do
{
float test0;
fibtemp fib1 + fib2;
counter counter + 1;
//now shuffle numbers held, discarding the oldest
fib0 fib1; //first move middle number, to overwrite oldest
fib1 fib2;
fib2 fibtemp;
}
while (counter<12):
//when reversing down, we will subtract fib0 from fib1 to form new fib0
do
{
fibtemp fib1 - fib0; //latest number now placed in fibtemp
counter counter - 1;
//now shuffle numbers held, discarding the oldest
fib2 fib1; //first move middle number, to overwrite oldest
fib1 fib0;
fib0 = fibtemp;
}
while (fib0>0);
go to loop
return 10;
}
tell me problem
WRITE A PROGRAM TO CONVERT A 2-DIGIT bcd NUMBER INTO HEXADECIMAL
#include<stdio.h> #include<conio.h> void main()
barsanabegam
Write your own prime number program and find out.
Try the triangle program on a search engine. Replace numbers with stars and that should do the trick
Exactly what do you mean by 'C program in Java'
#include #include void main(void) { int i,j,k,n; clrscr(); i=0; j=1; printf("%d %d ",i,j); for(n=0;n<=5;n++) { k=i+j; i=j; j=k; printf("%d ",k); } getch(); }
Just generate the Fibonacci numbers one by one, and print each number's last digit ie number%10.
//to generate Fibonacci series upto a range of 200....(in C).... #include<stdio.h> main() { int a,b,c,i; a=0; b=1; printf("\n FIBONACCI SERIES .....\t"); i=1; while(i<=(200-2)) { c=a+b; printf("\t%d",c); a=b; b=c; i++; } }
//WAP to print fibonacci series using do-while loop.? using System; class Fibonacci { public static void Main() { int a=1,b=1; int sum=0; Console.Write("Enter Limit:"); int n=Int32.Parse(Console.ReadLine()); Console.Write(a); Console.Write(b); do { sum=a+b; a=b; b=sum; Console.Write(sum); } while(sum<n); } } By-Vivek Kumar Keshari
write a c program to accept a number and generate a square root cube and exponential values
class Fibonacci { public static void main(String args[]) { System.out.println("enter the number upto u want"); int number=Integer.parseInt(args[0]); int a=0,b=1,c=0; System.out.print(a+" "+b); for(int i=1;i<=number;i++) { c=a+b; System.out.print(c+" "); a=b; b=c; } } } the number are given to the run time where are print the series eg: 5 0 1 1 2 3 5 8 13................
If you have the series stored in an array, you loop through the array and print each array element in turn. Another possibility is to print out the numbers in the series as you generate them. In that case, you may not need to store anything (depending on the series, of course).
#include<stdio.h> #include<conio.h> int fib(int a); main() { int a; clrscr(); scanf("%d",&a); for(int i=0;i<a;i++) printf("%d\n",fib(i)); } int fib(int a) { if(a==0) return 0; if(a==1) return 1; else return (fib(a-1)+fib(a-2)); }
#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; }
write a program to print the series 1/12+1/22+.........+1/n2 ?
#include#includevoid fibonacci(int x){int f=0,m=-1,n=1,i=0;while(i