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

how many argument we can pas in in a function

25 Answers   CTS,


#include<stdio.h> #include<conio.h> int main() { int a[4][4]={{5,7,5,9}, {4,6,3,1}, {2,9,0,6}}; int *p; int (*q)[4]; p=(int*)a; q=a; printf("\n%u%u",p,q); p++; q++; printf("\n%u%u",p,q); getch(); return 0; } what is the meaning of this program?

2 Answers  


if ENTERED FIVE DIGITS DESIGN A PROGRAM THAT WILL FIND CORRESPONDING VALUE FROM ASCII TABLE

1 Answers  


print the pattern 1 2 4 3 6 9 4 8 12 16 5 10 15 20 25 if n=5

3 Answers   Winit,


Which of the following about the C comments is incorrect ? a.commentscan go over multiple lines b.comments can start any where in the line c.a line can contain comments with out any language statements d.comments can occur within comments

6 Answers   TCS,






Would you rather wait for the results of a quicksort, a linear search, or a bubble sort on a 200000 element array? 1) Quicksort 2) Linear Search 3) Bubble Sort

3 Answers  


what are threads ? why they are called light weight processes ? what is the relation between process and threads ?

1 Answers  


Can the curly brackets { } be used to enclose a single line of code?

0 Answers  


What is sizeof in c?

0 Answers  


Why is conio.h not required when we save a file as .c and use clrscr() or getch() ?

2 Answers  


Is it valid to address one element beyond the end of an array?

0 Answers  


why division operator not work in case of float constant?

2 Answers  


Categories