i think there is something wrong with my compiler. i was trying to configure codeblocks to use mingw as the compiler.
i am trying to create a square root and exponents calculator. There are two if statements which calculate the value of either "sqrt_result" or "exp_result.Please tell me what is wrong.
These are the errors:
[Warning] converting to `long int' from `double'
[Linker error] undefined reference to `__cpu_features_init'
string second_operation;
shortint second_input_exp;
double second_input_sqrt;
longdouble sqrt_result;
longint exp_result;
int exp;
cout<< "Type in 'exp' if you wish to repeatedly multiply a number"<<endl;
cout<< "Type in 'sqrt' if you wish to find the square root of a number"<<endl;
cin >> second_operation;
}
if (second_operation == "exp")
{
cout<< "Enter the number you wish to calculate "<<endl;
cin >> second_input_exp;
cout << "Type in the exponent ";
cin >> exp;
exp_result = pow(second_input_exp,exp);
cout << second_input_exp<< "raised to the power of" << exp << "is equal to"<< exp_result;
}
if (second_operation == "sqrt")
{
cout<< "Enter the number you wish to calculate "<<endl;
cin >> second_input_sqrt;
sqrt_result = sqrt (second_input_sqrt);
cout << "The square root of " << second_input_sqrt<< "is equal to "<< sqrt_result;
}
The reason your program doesn't run is not the conversion from double to int (although I'd suggest fixing this because it may cause some unwanted precision loss), but the fact that somewhere in your code you are calling a function named cpu_features_init() (or something like this) but you haven't defined it. If this function is declared in some header file you include in your project, be sure that you link with the appropriate library (where the definition of this function lies) before compiling.