-
getting parse error
in function PrimeFactor
parse error before '0'
Code:
int PrimeFactor()
{
int y;
int fact;
int r,i;
int num1, num2, gpf;
enum { FALSE, true } Prime;
y=GetNum(num1);
Prime = TRUE;
gpf = floor(sqrt(y));
for(fact=2; fact <= gpf; fact++)
while( y % fact == 0)
/*i believe error is here but wuts wrong*/
{
if(Prime)
{
printf("%d = %d", y, fact);
Prime = FALSE;
}
else
{
printf(" * %d", fact);
y = y/fact;
}
if(Prime)
printf("%d is a prime number.", y);
else
if(y!=1)
{
printf(" * %d", y);
printf("\n\n");
}
else
printf("The Prime Factors for this number are\n");
printf("%d = ", y);
for (i=2; i <=y; i++)
{
while( y % i == 0)
{
y = y / i;
printf(" * %d",i);
}
}
}
}
printf("\n\n");
}
-
Here are a few items:
*1*
enum { FALSE, true } Prime;
Prime = TRUE;
The two words are not the same.
*2*
Code:
for(fact=2; fact <= gpf; fact++)
while( y % fact == 0)
Here you have nested loops. You may want this, but if you don't, I thought I'd just point it out.
On a side note, you should really use one common indentation. Either just use tabs, or just use spaces. Don't mix them, because it makes your code hard to read when you transport it from one editor to another. (Or into a form such as this.)
Quzah.