Hi guys I have to find the cubes of odd numbers between +17 to -17 using a while loop but for some reason I'm getting an infinite loop and I wonder if you guys could help me find the error.
Code:
//PROBLEM 1
//C
#include <stdio.h>
#include <math.h>
int cube(int y); //function prototype
int main(void)
{
int j; // inner counter
puts("PROBLEM 2 PART (C) - CUBES OF ODD NUMBERS FROM 17 TO -17 USING WHILE LOOP:\n\n X VALUES: \t\ FACTORIAL VALUES OF X: \t\t \n\n"); // display table headers and compute square value of i
// outer counter counting from -16 to 16
int i = 17;
while(i >= -17 )
{
i++;
if(i % 2 == 1 || i % 2 == -1)
{
int factor = 1;
j = 17;
while (j >= i)
{
factor = cube(j);
j++;
} // end inner for
printf("%d\t\t %d\t\t \n\n", i, cube(i));
}
}
return 0;
}
int cube(int y)
{
return y * y * y;
}