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
How will you find a duplicate number in a array without negating the nos ?
Explain output of printf("Hello World"-'A'+'B'); ?
Why c is called object oriented language?
What are the different types of objects used in c?
Where static variables are stored in c?
Explain data types & how many data types supported by c?
What do you mean by command line argument?
What are header files in c?
Explain the Difference between the New and Malloc keyword.
Which header file is used for clrscr?
What is sorting in c plus plus?
What is the package for freshers(Non IIT) in amazon(hyderabad). And what is the same for those who are a contract employee.
Explain what is the advantage of a random access file?
What is string constants?
Explain how do you list files in a directory?