double to int error

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'





The code:
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
string second_operation;
    short int second_input_exp;
    double second_input_sqrt;
    long double sqrt_result;
    long int 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;

                              }
Last edited on
What compiler do you recommend?
closed account (jwC5fSEw)
Uh, Dev-C++ isn't a compiler. It's an IDE.
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.
MinGW throws that error when there's more than one MinGW installation callable through the command line.
oh ok, nice to know
Topic archived. No new replies allowed.