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


Please Help Members By Posting Answers For Below Questions

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.

728


What is line in c preprocessor?

618


How do I get a null pointer in my programs?

629


How can you increase the size of a statically allocated array?

623


Are bit fields portable?

685






write a c program to find the sum of five entered numbers using an array named number

1625


Explain what is the heap?

632


write a program to create a sparse matrix using dynamic memory allocation.

4377


Why cant I open a file by its explicit path?

602


How arrays can be passed to a user defined function

583


What is actual argument?

600


Can we access array using pointer in c language?

650


What is a shell structure examples?

601


C program to find all possible outcomes of a dice?

1864


please explain every phase in the "SDLC" in the dotnet.

2182