![]() |
|
![]() |
|
|
Thread Tools | Display Modes |
|
|
#1 |
|
Hobbyist Programmer
Join Date: Mar 2006
Posts: 115
Rep Power: 3
![]() |
strange problem of compiling
Hi ,
I urgently need help . I make a program that compute the area of triangle. When I run my program on my computer everything is OK. But when I run it on the school system I get this compilation error: ld: Unresolved: sqrt My function is fixed ..I mean the argument types have been imposed. Please can someone help me I just have few hours left. #include<iostream>
#include<cmath>
#include<ctime>
#include<cstdlib>
using namespace std;
void compute_area(double&,double&,double,double,double);
int main()
{
double area,perimeter;
double a,b,c;
cout<<"Enter length a: ";
cin>>a;
cout<<endl;
cout<<"Enter length b: ";
cin>>b;
cout<<endl;
cout<<"Enter length c: ";
cin>>c;
cout<<endl;
compute_area(area,perimeter,a,b,c);
return 0;
}//end main
void compute_area (double& area, double& perimeter, double a, double b,
double c)
{
double s;
//s=0;
if( (a>(b+c))||(b>(a+c))||(c>(b+a)) )
{ cout<<"bad combination!"<<endl;
return;
}
else
{
s = (a + b + c)/ 2.0;
area = sqrt (s*(s-a)*(s-b)*(s-c));
perimeter=a+b+c;
cout << "The area of a triangle with sides of length " << a
<< ", " << b << " and " << c << " is " << area <<
" and its perimeter is "<<perimeter<< endl;
return;
}
} |
|
|
|
|
|
#2 |
|
Expert Programmer
Join Date: Jun 2005
Posts: 824
Rep Power: 4
![]() |
You need the libm library, try adding -lm to the compile line
|
|
|
|
|
|
#3 |
|
Hobbyist Programmer
Join Date: Mar 2006
Posts: 115
Rep Power: 3
![]() |
|
|
|
|
![]() |
| Bookmarks |
| Currently Active Users Viewing This Thread: 1 (0 members and 1 guests) | |
| Thread Tools | |
| Display Modes | |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| strange problem | brad sue | C++ | 3 | Sep 1st, 2006 8:50 AM |
| Strange Problem? | magic_e | PHP | 10 | Feb 9th, 2006 8:54 PM |
| cgi/perl script + IE problem | joyceshee | Perl | 2 | Jan 24th, 2006 11:10 AM |
| Problem Compiling this program | OUfanAP12 | Java | 4 | Nov 7th, 2005 7:27 PM |
| Compiling problem, please help. | os008 | C++ | 0 | Feb 5th, 2005 5:03 PM |