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

Hi how many types of software editions are there and their difference (like home editions, enterprise, standard etc) can u please help me

1468


When can a far pointer be used?

588


Define macros.

785


#include { printf("Hello"); } how compile time affects when we add additional header file .

1424


Write a program to generate the Fibinocci Series

667






any C program contains only one function, it must be a) void () b) main () c) message () d) abc ()

695


Write a program to swap two numbers without using third variable in c?

618


Differentiate between null and void pointers.

633


On most computers additional memory that is accessed through an adapter of feature card along with a device driver program. a) user memory b) conventional memory c) expandedmemory d) area

664


Explain what is the stack?

636


Why is c called c not d or e?

615


How can I get random integers in a certain range?

613


Does c have class?

613


What is the deal on sprintf_s return value?

645


What is a header file?

638