Programming Forums
User Name Password Register
 

RSS Feed
FORUM INDEX | TODAY'S POSTS | UNANSWERED THREADS | ADVANCED SEARCH

Reply
 
Thread Tools Display Modes
Old Sep 14th, 2006, 3:32 AM   #1
brad sue
Hobbyist Programmer
 
Join Date: Mar 2006
Posts: 115
Rep Power: 3 brad sue is on a distinguished road
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;
     }   
}
Thank you
brad sue is offline   Reply With Quote
Old Sep 14th, 2006, 4:51 AM   #2
The Dark
Expert Programmer
 
Join Date: Jun 2005
Posts: 824
Rep Power: 4 The Dark is on a distinguished road
You need the libm library, try adding -lm to the compile line
The Dark is offline   Reply With Quote
Old Sep 14th, 2006, 8:27 AM   #3
brad sue
Hobbyist Programmer
 
Join Date: Mar 2006
Posts: 115
Rep Power: 3 brad sue is on a distinguished road
Quote:
Originally Posted by The Dark View Post
You need the libm library, try adding -lm to the compile line
YES!! Thank you The Dark
brad sue is offline   Reply With Quote
Reply

Bookmarks

« Previous Thread in Forum | Next Thread in Forum »

Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Forum Jump

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




DaniWeb IT Discussion Community
All times are GMT -5. The time now is 9:23 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC