Write a program to generate prime factors of a given integer?
Answer Posted / sourav das
#include<stdio.h>
#include<conio.h>
void main()
{
int i,j,k,l,n;
clrscr();
printf("Enter The Number:");
scanf("%d",&n);
i=1;
while(i<=n)
{
if(n%i==0)
{
j=1;
k=0;
l=1;
while(l<=j)
{
if(j%l==0)
k++;
l++;
}
if(k==2)
{
printf("\n%d is the prime factor of %d",l-1,n);
}
}
i++;
}
getch();
}
| Is This Answer Correct ? | 26 Yes | 24 No |
Post New Answer View All Answers
How many parameters should a function have?
How can I generate floating-point random numbers?
Explain the difference between malloc() and calloc() function?
What are the advantages and disadvantages of a heap?
Explain what is the difference between a free-standing and a hosted environment?
formula to convert 2500mmh2o into m3/hr
What is a void pointer in c?
Explain how are 16- and 32-bit numbers stored?
What do header files do?
What is the scope of local variable in c?
Explain the array representation of a binary tree in C.
What is local and global variable in c?
write a program to find the given number is prime or not
Is it valid to address one element beyond the end of an array?
Difference between goto, long jmp() and setjmp()?