Need help with an error I'm getting!

The error I'm getting is [Warning] converting to 'long long int' from 'double'. I'm not sure why I'm getting this, if someone could take a quick look and see if you could help me out I'd appreciate it! The error is in the line termOne = pow(termOne , 0.5);

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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
#include <string>
#include <iostream>
#include <cmath>
#include <iomanip>

using namespace std;

const string STATE_ONE = "Enter the first term: ";
const string STATE_TWO = "Enter the number of terms to calculate (after first): ";
const string STATE_THREE = "Enter the terms to display per line: ";

int displayQuestions( string display );

int main()
{
    long long int termOne;
    int termCount;
    int numOfLines;
    int count;

    cout << "Program will determine the terms in a Juggler Series" << endl << endl;

    termOne = displayQuestions( STATE_ONE );

    termCount = displayQuestions( STATE_TWO );

    numOfLines = displayQuestions( STATE_THREE );

    cout << "First " << termCount << " terms of JUGGLER SERIES starting with " << termOne << endl;

    count = 0;

    do
    {
        if (termOne % 2 == 0 )
        {
            termOne = pow(termOne , 0.5);
            cout << setw(15) << termOne ;
            count++;
            	if ((count % numOfLines) == 0)
	               {
                       cout << "\n";
                   }
        }
        if (termOne % 2 != 0 )
        {
            firstTerm = pow(termOne, 1.5);
            cout << setw(15) << termOne ;
            count++;
            	if ((count % numOfLines) == 0)
                {
                    cout << "\n";
                }            
        }
    }
    while (count <= termCount);

    cout << endl;
    system("Pause");
    return 0;
}


int displayQuestions( string display )
{
    int userNum;
    cout << display << endl;
    cin >> userNum;

    while ( userNum <= 0 )
    {      
        cout << "Enter a positive number" << endl;
        cin >> userNum;
    } 

    return userNum;  
}


erm.. no overloaded version pow() function returns a long long int:
http://www.cplusplus.com/reference/cmath/pow/


p.s. a warning isn't an error. however it is good practice to address all warnings too.
Last edited on
Line 37:
1
2
// firstTerm = pow(termOne, 1.5); // *** error: 'firstTerm' was not declared in this scope
termOne = pow(termOne, 1.5);
Topic archived. No new replies allowed.