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

Answer Posted / courage

#include<stdio.h>

int main()

{

int num=0;

printf("Enter number\n");

scanf("%d",&num);

int i,count=0,j;

for (i=1;i<=num;i++)

{

if (num%i==0)

{

for (j=1;j<=i;j++)

{

if(i%j==0)

{

count=count+1;

}

}

if (count==2)

{

printf("%d",i);

}

count=0;




}

}

}

Is This Answer Correct ?    4 Yes 16 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Explain what is wrong with this statement? Myname = ?robin?;

990


When c language was developed?

632


I just typed in this program, and it is acting strangely. Can you see anything wrong with it?

557


Why we write conio h in c?

555


why to assign a pointer to null sometimes??how can a pointer we declare get assigned with a garbage value by default???

1510






What does *p++ do?

577


while loop contains parts a) initialisation, evalution of an expression,increment /decrement b) initialisation, increment/decrement c) condition evalution d) none of the above

732


What is extern c used for?

563


pierrot's divisor program using c or c++ code

1724


Which is more efficient, a switch statement or an if else chain?

571


explain what is an endless loop?

607


Is the exit() function same as the return statement? Explain.

656


Explain why C language is procedural?

766


What is the benefit of using #define to declare a constant?

601


What are the scope of static variables?

597