I was trying to develop a code to compute the [prime factors][1] of a number, but I am getting nothing as output. Can anyone point out where I am making the mistake?
#include<stdio.h>
#include<math.h>
int prime_check(int i)
{
int j;
for(j=2;j<i;j++)
{
if(i%j==0)
return 0;
}
return i;
}
void prime(int n)
{
double c=sqrt(n);
int i;
int p[10];
//printf("factors are: ");
for(i=1;i<=c;i++)
{
p[i]=prime_check(i);
//printf("%d ",p[i]);
if(n % p[i] == 0)
printf("%d ",p[i]);
}
}
main()
{
//printf("enter the number:\t");
int num=36;
//scanf("%d",&num);
prime(num);
}
TO EVERYONE I GOT THE ANSWER! Thanks Jeff Mercado for showing me my mistake
1 Answer