#include<stdio.h>
main()
{
static int n=0, number=1; 
int fibi (int n, int number);
printf ("Following are the first 40 Numbers of the Fibonacci Series:\n");
printf ("1 ");
fib (n,number);
}
fib (int n, int number)
{
static int i=1; 
int fibo;
if (i==40)
{
printf ("\ndone"); 
}
else 
{
fibo=n+number;
n=number;
number=fibo; 
printf ("\n%d", fibo);
i++; 
fib (n,number); 
}
}

my program shows the following.
1
2
3
5
8
13
21
34
55
89
144
233
377
610
987
1597
2584
4181
6765
10946
17711
28657
46368
75025
i want my program to show
1
2 prime
3 prime
5 prime
8
13 prime
21
34
55
89 prime
144
233 prime
377
610
987
1597 prime
2584
4181
6765
10946
17711
28657 prime
please help me!!!!!!

[edit] I've just read your other thread, which made this post obsolete..[/edit]
Niek

hi
u had a gud try recursion
try this code a simple modification to your code

#include<stdio.h>
#include<conio.h>
main()
{
static long int n=0, number=1;
void fibi (long int ,long int );
printf ("Following are the first 40 Numbers of the Fibonacci Series:\n");
printf (" 1 ");
fibi (n,number);
getch();
}
void fibi (long int n,long int number)
{
int flag=0,pi;
static int i=1;
long int fibo;
if (i==40)
{
printf ("\ndone");
}
else
{
fibo=n+number;/* fibo is number in fibbinoci series*/
n=number;
number=fibo;
/* checking the number for primeness*/
for(pi=2;pi<fibo;pi++)
{
if(fibo%pi==0)
{
flag=0;
break;
}
else
flag=1;
}
if(fibo==2)
{
flag=1;
}
if(flag==1)
{
printf("\n %ld prime",fibo);
}
else
printf ("\n %ld", fibo);
i++;
fibi (n,number);
}
}

well u could even use a function with fibo as argument

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.