im writing a program that checks for "magic numbers" what it does is add 1 +2+3+4+5... and checks to see if each is a perfect square. my problem is that modulus doesnt work it gives me a illegal operand error every time.
why is this?
here is the code im using
my problem is just in the loopCode:void MagNum(int num, int mag) { int temp = num, counter = 1; double test, square; temp ++; while (counter <= num) { square = sqrt(double (mag)); test = square % 1; if(test == 0) { counter ++; cout << "Magic number = " << mag; mag = temp + mag; } else { mag = temp + mag; } } }
Code tags added by kermi3