What is going on with this "simple" code???

No matter how I rewrite it, I can't get the sqrt function or even the pow function to make a legitimate DOUBLE output! I swear, when I originally submitted this file, it worked, and made a table (haphazard as FUCK) with double floating point values for all the Fun (iX, iY) outputs. Can anyone see my error??

#include <iostream>
#include <math.h>

using namespace std;

int Fun (double iX, double iY)
{return sqrt(iX*iX+iY*iY);}

int main (void)
{double iX =1.0, iY=1.0;
cout << "\t 1\t2\t\t3\t\t4\t\t5"<<endl;
cout <<"1\t";
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
cout <<"2\t";
iY=2.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
cout <<"3\t";
iY=3.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
cout <<"\n4\t";
iY=4.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
cout <<"\n5\t";
iY=5.0;
iX=1.0;
for (iX=1.0; iX<=5.0; iX++)
{cout << Fun (iX,iY) << "\t " ;}
return 1;}
Your function declares that it returns an int.
Topic archived. No new replies allowed.