c++ - C2106 Error in Simple Math Program -
#include <tchar.h> #include <stdio.h> #include <iostream> using namespace std; int main() { int = (1024^3)-(639^3)-(385^3); short max = 0; cout<< " prints 0 if no answer." << endl; for(int iii = 100; iii < 1000; iii++) { if(a % iii = 0) { max = iii; } } cout<< " " << max; cin.clear(); cin.ignore(); cin.get(); return 0; }
just trying write simple program don't have calculate , compiler returns c2106 error line 14.
if (a % iii = 0)
this invalid assignment. if meant compare, use comparison operator ==
.
if (a % iii == 0)
moreover, exponentiation not done ^
in c++. bitwise xor
operator. exponentation, use std::pow
<cmath>
header.
#include <cmath> int main() { int = std::pow(1024, 3) - std::pow(639, 3) - std::pow(385, 3); }