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
What are header files? What are their uses?
Explain bit masking in c?
Explain what is the stack?
what is the height of tree if leaf node is at level 3. please explain
how to construct a simulator keeping the logical boolean gates in c
main() { struct s1 { char *str; struct s1 *ptr; }; static struct s1 arr[] = { {"Hyderabad",arr+1}, {"Bangalore",arr+2}, {"Delhi",arr} }; struct s1 *p[3]; int i; < BR> for(i=0;i<=2;i++) p[i] = arr[i].ptr; printf("%s ",(*p)->str); printf("%s ",(++*p)->str); printf("%s ",((*p)++)->str); }
what is the difference between north western polytechnique university and your applied colleges?? please give ur answers for this. :)
application areas a 'c' a) operating system b) graphics, interpreter, assembler c) program evalution, communication softwares d) all the above
Can a variable be both constant and volatile?
What is infinite loop?
What are the c keywords?
What is size of union in c?
how can use subset in c program and give more example
Do you know what are bitwise shift operators in c programming?
What is the difference between printf and scanf in c?