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

Answer Posted / ruchi

#include<stdio.h>
#include<conio.h>
int main()
{
int num,i,f=0,k=0,d,m;
printf("\n Enter the number ");
scanf("%d",&num);
m=num;
while(k<=m)
{
k=k+1;
f=0;
d=num%k;
if(d==0)
{
i=2;
while(i<=k-1)
{
if(k%i==0)
{
break;
}
i++;
}
if(i==k)
{
printf("\nPrime Factor %d ",k);
}
}
}
getch();
}

Is This Answer Correct ?    6 Yes 0 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

1.int a=10; 2.int b=20; 3. //write here 4.b=30; Write code at line 3 so that when the value of b is changed variable a should automatically change with same value as b. 5.

1901


Can include files be nested?

829


What is action and transformation in spark?

817


Is c programming hard?

765


Explain how can type-insensitive macros be created?

756


Where static variables are stored in memory in c?

703


What is a structure in c language. how to initialise a structure in c?

819


What does p mean in physics?

794


Read the following data in two different files File A: aaaaaaaadddddddd bbbbbbbbeeeeeeee ccccccccffffffff File B: 11111111 22222222 33333333 By using the above files print the following output or write it in the Other file as follows aaaaaaaa11111111dddddddd bbbbbbbb22222222eeeeeeee cccccccc33333333ffffffffffff

2739


Explain what is the difference between a string and an array?

880


What does struct node * mean?

792


Can a program have two main functions?

834


What is use of pointer?

771


What does int main () mean?

753


Design a program which assigns values to the array temperature. The program should then display the array with appropriate column and row headings.

2069