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 is a structure member accessed?
why arguments can generally be passed to functions a) sending the values of the arguments b) sending the addresses of the arguments c) a & b d) none of the above
hi folks i m approching for h1 b interview on monday 8th of august at montreal and i m having little problem in my approval notice abt my bithdate my employer has made a mistake while applying it is 12th january and istead of that he had done 18 the of january do any body have any solution for that if yes how can i prove my visa officer abt my real birthdate it urgent please let me know guys thaks dipesh patel
what are the different storage classes in c?
How can I determine whether a machines byte order is big-endian or little-endian?
Explain union.
Explain how can type-insensitive macros be created?
The % symbol has a special use in a printf statement. Explain how would you place this character as part of the output on the screen?
Are there any problems with performing mathematical operations on different variable types?
Why is c called c?
Write a program with dynamically allocation of variable.
Should I use symbolic names like true and false for boolean constants, or plain 1 and 0?
What is the role of && operator in a program code?
how can i access hard disk address(physical address)? are we access hard disk by using far,near or huge pointer? if yes then please explain.....
What is the difference between exit() and _exit() function?