Nebula
05-01-04, 12:12 AM
Sorry for cluttering this forum with my newb questions ;).
One of my latest assignments is to write a small prog that calculates the area of an octagon.
#include <iostream.h>
#include <math.h>
#define oct_const 4.828
int main()
{
float a, area_octagon;
cout << "Enter the length of one side: ";
cin >> a;
area_octagon = oct_const * pow(a,2);
cout << "The area of the octagon with side length " << a <<" = ";
cout.precision(3);
cout.setf(ios::showpoint | ios::fixed);
cout<< area_octagon << endl << endl;
return 0;
}
When I build it I get a warning from line 15 "conversion from 'double' to 'float', possible loss of data". It still compiles, but I can't get rid of this warning. I've tried casting it as a double but it still doesn't work!
What am I doing wrong?
Thanks again!
One of my latest assignments is to write a small prog that calculates the area of an octagon.
#include <iostream.h>
#include <math.h>
#define oct_const 4.828
int main()
{
float a, area_octagon;
cout << "Enter the length of one side: ";
cin >> a;
area_octagon = oct_const * pow(a,2);
cout << "The area of the octagon with side length " << a <<" = ";
cout.precision(3);
cout.setf(ios::showpoint | ios::fixed);
cout<< area_octagon << endl << endl;
return 0;
}
When I build it I get a warning from line 15 "conversion from 'double' to 'float', possible loss of data". It still compiles, but I can't get rid of this warning. I've tried casting it as a double but it still doesn't work!
What am I doing wrong?
Thanks again!