Write a program to generate prime factors of a given integer?
Answer Posted / rajesh kumar s
int main()
{
int n,num,i;
printf("enter the num");
scanf("%d",&num);
n=num;
printf("\n");
for(i=2;i<=n/2;i++)
{
if(n%i==0)
{
prime(i);
}
}
}
void prime(int x)
{
int i,f=0;
for(i=2;i<=x/2;i++)
{
if(x%i==0)
{
f=1;
break;
}
}
if(f==0)
printf(" %d",x);
}
| Is This Answer Correct ? | 49 Yes | 40 No |
Post New Answer View All Answers
Explain how can a program be made to print the name of a source file where an error occurs?
find the value of y y = 1.5x+3 for x<=2 y = 2x+5 for x>2
write a program that declares an array of 30 elements named "income" in the main functions. then cal and pass the array to a programmer-defined function named "getIncome" within the "getIncome" function, ask the user for annual income of 30 employees. then calculate and print total income on the screen using the following function: "void getIncome ( ai []);
the statement while(i) puts the entire logic in loop. this loop is called a) indefinite loop b) definite loop c) loop syntax wrong d) none of the above
What is the advantage of an array over individual variables?
What is NULL pointer?
What is string length in c?
Why is not a pointer null after calling free? How unsafe is it to use (assign, compare) a pointer value after it is been freed?
Who developed c language?
Can a local variable be volatile in c?
When was c language developed?
Is it better to bitshift a value than to multiply by 2?
When I tried to go into a security sites I am denied access and a message appeared saying 'applet not initialize'. How can I rectify this problem.
What are the two forms of #include directive?
What is the importance of c in your views?