Write a program to generate prime factors of a given integer?

Answer Posted / neha

#include<stdio.h>
#include<conio.h>
int main()
{
int num,i=1,j,k;
printf("\n\tEnter the number:");
scanf("%d",&num);
while(i<=num)
{
k=0;
if(num%i==0)
{
j=1;
while(j<=i)
{
if(i%j==0)
k++;
}
j++;
if(k==2)
printf("\n\t%d is a Prime factor:"i);
}
i++;
}
return 0;
}

Is This Answer Correct ?    3 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

Can include files be nested?

833


Why is this loop always executing once?

802


The program will first compute the tax you owe based on your income. User is prompted to enter income. Program will compute the total amount of tax owed based on the following: Income Tax 0 - $45,000 = 0.15 x income $45,001 - $90,000 = 6750 + 0.20 x (income – 45000) $90,001 - $140,000 = 15750 + 0.26 x (income – 90000) $140,001 - $200,000 = 28750 + 0.29 x (income – 140000) Greater than $200,000 = 46150 + 0.33 x (income – 200000) Dollar amounts should be in dollars and cents (float point numbers with two decimals shown). Tax is displayed on the screen.

1289


What functions are in conio h?

886


What are the different file extensions involved when programming in C?

1014


How many header files are in c?

748


What is the use of static variable in c?

817


hello freinds next week my interview in reliance,nybody has an idea about it intervew questions..so tell

1949


Explain spaghetti programming?

951


Explain what’s a signal? Explain what do I use signals for?

789


Explain how can you check to see whether a symbol is defined?

867


What does void main return?

837


Explain setjmp()?

826


Write a factorial program using C.

837


Explain how do you sort filenames in a directory?

801