Write a program to generate prime factors of a given integer?
Answer Posted / ruchi
#include<stdio.h>
#include<conio.h>
int main()
{
int num,i,f=0,k=0,d,m;
printf("\n Enter the number ");
scanf("%d",&num);
m=num;
while(k<=m)
{
k=k+1;
f=0;
d=num%k;
if(d==0)
{
i=2;
while(i<=k-1)
{
if(k%i==0)
{
break;
}
i++;
}
if(i==k)
{
printf("\nPrime Factor %d ",k);
}
}
}
getch();
}
| Is This Answer Correct ? | 6 Yes | 0 No |
Post New Answer View All Answers
What are types of preprocessor in c?
How can I make sure that my program is the only one accessing a file?
Explain how can I write functions that take a variable number of arguments?
Explain spaghetti programming?
What is c language & why it is used?
What is the difference between test design and test case design?
I have written a pro*C program to fetch data from the cursor. where in i have used the concept of BULK FETCH.... each FETCH statement is taking lots of time to fetch specified number of rows at...
What is sizeof int?
Why c is called free form language?
What is the advantage of using #define to declare a constant?
why use functions a) writing functions avoids rewriting the same code over and over b) using functions it becomes easier to write programs and keep track of what they are doing c) a & b d) none of the above
What type of function is main ()?
What’s the special use of UNIONS?
Are negative numbers true in c?
Why doesnt long int work?