write a program to generate 1st n fibonacci prime number

Answers were Sorted based on User's Feedback



write a program to generate 1st n fibonacci prime number..

Answer / swapna

#include <stdio.h>
#include <conio.h>
void main ( )
{
long a,b,c,i,n,j;
clrscr( );
printf ("\n Enter the number to print fibnocci
prime number\t");
scanf ("%ld",&n);
a=0;
b=1;
for (i=1; i<n; i++)
{
c=a+b;
a=b;
b=c;
printf ("\n fibnoci series is %ld\t",c);
for(j=2;j<c;j++)
{
if(c%j==0)
break;
}
if(c==j)
printf(" prime number is %ld\t",c);
}
getch();
}

Is This Answer Correct ?    89 Yes 39 No

write a program to generate 1st n fibonacci prime number..

Answer / rajesh kumar s

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 ?    26 Yes 14 No

write a program to generate 1st n fibonacci prime number..

Answer / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int n,a=1,b,c=0,d=0,i,j;
printf("\nenter the number ");
scanf("%d",&n);
printf("\nThe fibbonacci prime numbers are ");
for(i=0;i<=n-1;i++)
{
b=c+a;
a=c;
c=b;
j=2;
while(j<=b-1)
{

if(b%j==0)
{

break;
}
j++;
}
if(j==b)
{
printf("\n%d",b);
}

}
getch();
}

Is This Answer Correct ?    16 Yes 6 No

write a program to generate 1st n fibonacci prime number..

Answer / abdifatah mohiadin adam

void main()
{
int x1,x2,x3,n,i;
x1=0;
x2=1;
printf("enter a value for n : ");
scanf("%d",&n);
printf("%d %d ",x1,x2);
for(i=3;i<=n;i++)
{
x3=x1+x2;
printf("%d ",x3);
x1=x2;
x2=x3;
}
}

Is This Answer Correct ?    9 Yes 8 No

write a program to generate 1st n fibonacci prime number..

Answer / subhabrato das

/*program to calculate lcm of 2 integers*/
#include"stdio.h"
#include"conio.h"
int lcm(int,int);
void main()
{
int a,b,lcm;
printf("Enter two integers...\n");
scanf("%d %d",&a,&b);
lcm=(a,b);
printf("\n\nLCM=%d",lcm);
}
int lcm(int a,int b)
{
int lcm;
int i=1;
while(1)
{
r=a*i;
if(r%b==0)
{
return r;
}
i++
}
}

Is This Answer Correct ?    6 Yes 6 No

write a program to generate 1st n fibonacci prime number..

Answer / 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

write a program to generate 1st n fibonacci prime number..

Answer / nirupam mondal

#include <stdio.h>
void main ( )
{
long a,b,temp,i,n,j;
printf ("Enter the limit upto which you wantto print the fibonacci series : ");
scanf ("%ld",&n);
a=0;
b=1;
for (i=1; i<n; i++)
{
printf ("
%ld ",temp);
temp=a+b;
a=b;
b=temp;
for(j=2;j<temp;j++)
{
if(temp%j==0)
break;
}
if(temp==j)
printf(" The corresponding prime numbers of the series are : %ld ",temp);
}
}

Is This Answer Correct ?    0 Yes 3 No

write a program to generate 1st n fibonacci prime number..

Answer / yagneswara babu

void main()
{
int x1,x2,x3,n,i;
x1=0;
x2=1;
printf("enter a value for n : ");
scanf("%d",&n);
printf("%d %d ",x1,x2);
for(i=3;i<=n;i++)
{
x3=x1+x2;
printf("%d ",x3);
x1=x2;
x2=x3;
}
}

Is This Answer Correct ?    35 Yes 40 No

write a program to generate 1st n fibonacci prime number..

Answer / kamlesh shewar

enter a value for n :
7
0 1 1 2 3 5 8

Is This Answer Correct ?    4 Yes 9 No

write a program to generate 1st n fibonacci prime number..

Answer / rose

void main()
{
int x1,x2,x3,i,n;
x1=-1;
x2=1;
printf("enter the value for n :");
scanf("%d",&n);
print
for(i=0;i<n;i++)
{
x3=x1+x2;

if((x3 mod 2)!=0)
{
printf("%d ",x3)
}
x1=x2;
x2=x3;
}

}

Is This Answer Correct ?    6 Yes 12 No

Post New Answer

More C Interview Questions

What are data structures in c and how to use them?

0 Answers  


though sbi was nationalized why its not comes under nationalized banks and its comes under publicsector banks

3 Answers   State Bank Of India SBI,


Find greatest number out of 10 number without using loop.

5 Answers   TCS,


What is meant by int main ()?

0 Answers  


what does keyword ‘extern’ mean in a function declaration?

1 Answers   Emerson,






what is the syallabus of computer science students in group- 1?

0 Answers  


What is the explanation for the dangling pointer in c?

0 Answers  


What is the argument of a function in c?

0 Answers  


How important is structure in life?

0 Answers  


Why enum is used in c?

0 Answers  


wtite a program that will multiply two integers in recursion function

4 Answers   TCS,


Why doesnt the call scanf work?

0 Answers  


Categories