2dix-The Student Choice
Log in Register now

c++ Program of PRIME FACTORS OF A NUMBER

Write a Program of  PRIME FACTORS OF A NUMBER

#include<iostream.h> 
#include<conio.h> 

void main()
{
int num,i=1,j,k;
clrscr();
printf("\nEnter a 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%d is a prime factor",i);
}
i++;
}
getch();
}


Note:    
           If you want to change in this program please write through the comment on this page. you can also past similar program of 
             c++ with output.your comment is valuable to the other user and person.

comments (1)

avatar