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

What is a stream water?

658


hi friends how r u as soon in satyam my interview is start but i m very confusued ta wat i do plz help me frndz wat can i do plz tell me some question and answers related with "C" which r asked in the interview .

1901


Which is the best website to learn c programming?

582


An expression to whose value an operater is applied a) operand b) variable c) constant d) all of the above

658


What is difference between main and void main?

630






Calculate the weighted average of a list of n numbers using the formula xavg = f1x1+f2x2+ ….+ fnxn where the f’s are fractional weighting factors, i.e., 0<=fi<1, and f1+f2+….+fn = 1

3661


write a program in c language to print your bio-data on the screen by using functions.

6251


Describe the order of precedence with regards to operators in C.

633


What is meant by recursion?

632


Why is this loop always executing once?

617


What is a memory leak? How to avoid it?

577


What is output redirection?

693


Do character constants represent numerical values?

844


Give basis knowledge of web designing ...

1575


Is fortran faster than c?

582