Write a program to generate prime factors of a given integer?
Answer Posted / mohammad nasim
include<stdio.h>
main()
{
int n;
printf("Enter a positive integer: ");
scanf("%d",&n);
printf("\nThe prime factors are:\n");
while((n/2)!= 0 || (n/3)!=0)
{
if(n%2==0)
{
printf("\t2");
n=n/2;
}
else
{
if(n%3==0)
{
printf("\t3");
n = n/3;
}
else
{
printf("\t%d",n);
break;
}
}
}
}
Is This Answer Correct ? | 1 Yes | 6 No |
Post New Answer View All Answers
Find the second largest element in an array with minimum no of comparisons and give the minimum no of comparisons needed on an array of size N to do the same.
What is line in c preprocessor?
How do I get a null pointer in my programs?
How can you increase the size of a statically allocated array?
Are bit fields portable?
write a c program to find the sum of five entered numbers using an array named number
Explain what is the heap?
write a program to create a sparse matrix using dynamic memory allocation.
Why cant I open a file by its explicit path?
How arrays can be passed to a user defined function
What is actual argument?
Can we access array using pointer in c language?
What is a shell structure examples?
C program to find all possible outcomes of a dice?
please explain every phase in the "SDLC" in the dotnet.