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 examples of structures?
What is a string?
given post order,in order construct the corresponding binary tree
What is volatile, register definition in C
What is the use of linkage in c language?
Differentiate between the expression “++a” and “a++”?
What is the full form of getch?
Can you pass an entire structure to functions?
how to introdu5ce my self in serco
What are the functions to open and close file in c language?
What are the rules for the identifier?
What is scope rule of function in c?
what will be the output for the following main() { printf("hi" "hello"); }
How can I recover the file name given an open stream or file descriptor?
Explain the difference between malloc() and calloc() function?