write a program to generate 1st n fibonacci prime number

Answer Posted / jagannath

#include<stdio.h>
#include<conio.h>

int main()
{
int f=0,s=1,t=1,n,fl;
printf("enter the limit\t:");
scanf("%d",&n);
printf("\nfirst %d prime fibonacci numbers
are\n",n);
while(n)
{
fl=0;
fl=prime(f);
if(f>1 && fl==1)
{
printf("%d\t",f);
n=n-1;
}
s=t;
t=f;
f=s+t;
}
}

int prime(int x)
{
int i,f=0;
for(i=2;i<=x/2;i++)
{
if(x%i==0)
{
f=1;
break;
}
}
if(f==0)
{
return 1;
}
else
return 0;

}

Is This Answer Correct ?    4 Yes 6 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What will be your course of action for a push operation?

661


Is c++ based on c?

644


Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?

596


Write a program to generate random numbers in c?

658


What are the various types of control structures in programming?

623






Can we assign string to char pointer?

580


Why clrscr is used in c?

577


How can variables be characterized?

1641


Are there namespaces in c?

562


How can my program discover the complete pathname to the executable from which it was invoked?

658


Write an efficient algo and C code to shuffle a pack of cards.. this one was a feedback process until we came up with one with no extra storage.

655


Is array a primitive data type in c?

573


Can we access the array using a pointer in c language?

556


program to find error in linklist.(i.e find whether any node point wrongly to previous nodes instead of next node)

1619


What is a stream in c programming?

588