Golgappa.net | Golgappa.org | BagIndia.net | BodyIndia.Com | CabIndia.net | CarsBikes.net | CarsBikes.org | CashIndia.net | ConsumerIndia.net | CookingIndia.net | DataIndia.net | DealIndia.net | EmailIndia.net | FirstTablet.com | FirstTourist.com | ForsaleIndia.net | IndiaBody.Com | IndiaCab.net | IndiaCash.net | IndiaModel.net | KidForum.net | OfficeIndia.net | PaysIndia.com | RestaurantIndia.net | RestaurantsIndia.net | SaleForum.net | SellForum.net | SoldIndia.com | StarIndia.net | TomatoCab.com | TomatoCabs.com | TownIndia.com
Interested to Buy Any Domain ? << Click Here >> for more details...

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

Answer Posted / shruthi chandran

voiid primeFactors(int n)
{
while (n%2 == 0)
{
printf("%d ", 2);
n = n/2;
}
for (int i = 3; i <= sqrt(n); i = i+2)
{

while (n%i == 0)
{
printf("%d ", i);
n = n/i;
}
}

if (n > 2)
printf ("%d ", n);
}

Is This Answer Correct ?    0 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

What is void main () in c?

1167


Explain what does it mean when a pointer is used in an if statement?

1028


How are 16- and 32-bit numbers stored?

1259


What is the difference between single charater constant and string constant?

1056


There seem to be a few missing operators ..

1018


What is #error and use of it?

1222


Write a program in c to replace any vowel in a string with z?

1091


Are comments included during the compilation stage and placed in the EXE file as well?

1047


What is bash c?

975


Why is c so important?

1012


How is null defined in c?

1120


What is operator promotion?

1024


Hi can anyone tell what is a start up code?

2031


Explain what is a stream?

1049


What is external variable in c?

1030