How do I solve this error? (C+)

Duo

Registered
The error is on line 17. I have no idea what it means or how to get rid of it. Can you guys help?


1:
2: #include <iostream.h> // include system information
3:
4: int main()
5: { int floatnum1, floatnum2, sur, floatpi;
6:
7: // display initial program identification
8: cout << "C Program 2 CSCE 1020.002" << endl
9: << "Corey Jones Cjtx6362@yahoo.com" << endl << endl;
10:
11: // prompt the user for input
12: cout << "Please enter washer's outer radius: ";
13: cin >> floatnum1;
14: cout << "Please enter washer's inner radius: ";
15: cin >> floatnum2;
16:
17: floatpi = 3.1415;
warning: assignment to 'int' from 'double'
18: sur = floatnum1 * floatnum1 * floatpi - floatnum2 * floatnum2 * floatpi;
19: cout << "The surface area of one of the washer's side is " << sur << endl;
20:
21: return 0;
22: }
23:
24:
 
You declared the variable floatpi as an integer. You can't give an integer variable a floating-point value. Change the variable declaration in line 5 from int to either float or double.
 
Back
Top