why do i get this compiling error with the following code??
numbers.c: In function `main':
numbers.c:33: `for' loop initial declaration used outside C99 mode
int main() {
int oneNumber =0; // hold the valid integer entered
int countPositiveFactors =0; // accumulate a sum , so should be initialize to 0
int sumPositiveFactors =0; // accumulate a sum , so should be initialize to 0
int prodPositiveFactors = 1; // accumulate a product so should be initialize to 1
while (1)
{
printf("Enter an integer > 1 :");
scanf("%d", &oneNumber);
if (oneNumber > 1)
break;
else
printf("Error: Number should be > 1\n");
_flushall(); // to flush all streams e.g. stdin
}
printf("\n\nHere is a list of the positive factors of %d\n",oneNumber);
for (int i=1;i<=oneNumber;i++)
{
if (oneNumber%i==0) // one factor found
{
countPositiveFactors++; // add 1 to count of positive factors
printf("%d ",i); // print this factor
sumPositiveFactors+=i; // add this factor e.g. i to the sum
prodPositiveFactors*=i; // multiply this factor with the previous factors
}
}
printf ("\n\nThe number of positive factors of %d is %d.\n",oneNumber, countPositiveFactors);
printf ("The sum of the positive factors of %d is %d.\n",oneNumber, sumPositiveFactors);
printf ("The product of the positive factors of %d is %d.\n",oneNumber, prodPositiveFactors);
return 0;
}