Write a program to generate prime factors of a given integer?

Answer Posted / rajesh kumar s

int main()
{
int n,num,i;
printf("enter the num");
scanf("%d",&num);
n=num;
printf("\n");
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
prime(i);
}
}
}

void prime(int x)
{
int i,f=0;
for(i=2;i<=x/2;i++)
{
if(x%i==0)
{
f=1;
break;
}
}
if(f==0)
printf(" %d",x);

}

Is This Answer Correct ?    49 Yes 40 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

write an algorithm to display a square matrix.

2216


How are portions of a program disabled in demo versions?

741


What is enumerated data type in c?

617


Explain modulus operator. What are the restrictions of a modulus operator?

595


Which is not valid in C a) class aClass{public:int x;}; b) /* A comment */ c) char x=12;

603






Write a programme using structure that create a record of students. The user allow to add a record and delete a record and also show the records in ascending order.

1617


What is difference between union and structure in c?

568


What is return in c programming?

507


What are integer variable, floating-point variable and character variable?

600


What are the advantage of c language?

546


What is the difference between variable declaration and variable definition in c?

557


What is operator precedence?

637


Explain about C function prototype?

600


Do you have any idea about the use of "auto" keyword?

660


What will be the outcome of the following conditional statement if the value of variable s is 10?

755