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
which of the following is allowed in a "C" arithematic instruction a) [] b) {} c) () d) none of the above
What is a program flowchart and explain how does it help in writing a program?
What is the purpose of the statement: strcat (S2, S1)?
Here is a good puzzle: how do you write a program which produces its own source code as output?
Explain what does the characters 'r' and 'w' mean when writing programs that will make use of files?
What is the sizeof () a pointer?
What is a program flowchart and how does it help in writing a program?
When should you not use a type cast?
Explain what is the stack?
What do you mean by dynamic memory allocation in c?
What is the use of pragma in embedded c?
in iso what are the common technological language?
Explain how can you tell whether two strings are the same?
Explain what are the different data types in c?
Place the #include statement must be written in the program?