I am new at programming and need help:

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int a, b, c, area, tri_area;

area = tri_area(a, b, c);

if area (area>0);
cout << "Area is "<<area<<"!"<<endl;
cout << " Those values tri_angle " <<endl;


}
double tri_area (double a, double b, double c)
{
    double s, t, area;
    s = (a + b + c)/2;
    t = s*(s-a)*(s-b)*(s-c);
    if (t>0)
        area=sqrt(t);
    else area = -1;
    return area;
}

Edited 3 Years Ago by pyTony: fixed formating

Hello,

For future reference, you might want to explain more on what the problem is... there are a variety of evaluations, and you did not specify which one was the faulty one.

I have a problem with this line:

if area (area>0);

What are you trying to evaluate here? Did you realize that by placing the ; after the expression, that you don't have a "then" part?" I think you need to re-work this evaluation/control logic.

Christian

I am new at programming and need help:

#include <iostream>
#include <cmath>
using namespace std;

int main()
{
int a, b, c, area, tri_area;

area = tri_area(a, b, c);

if area (area>0);
cout << "Area is "<<area<<"!"<<endl;
cout << " Those values tri_angle " <<endl;


}
double tri_area (double a, double b, double c)
{
    double s, t, area;
    s = (a + b + c)/2;
    t = s*(s-a)*(s-b)*(s-c);
    if (t>0)
        area=sqrt(t);
    else area = -1;
    return area;
}

Looks like you are mixing pseudo code with code! Somehow you have to give values to a, b and c. Don't mix int and double, pick one or the other. The list goes on ...

Edited 3 Years Ago by pyTony: fixed formating

Hello,

For future reference, you might want to explain more on what the problem is... there are a variety of evaluations, and you did not specify which one was the faulty one.

I have a problem with this line:

if area (area>0);

What are you trying to evaluate here? Did you realize that by placing the ; after the expression, that you don't have a "then" part?" I think you need to re-work this evaluation/control logic.

Christian

I am trying to write a program that inputs the lengths of sides of a triangle. then output the area of a triangle. by using a double valued function called tri_area

int a, b, c, area, tri_area;
// computer reads your mind to find out what values a, b, and c should have
area = tri_area(a, b, c);

Plus much, much more.

Do you have a specific question?

i see a lot wrong with this and i'm not that experienced a programmer but i do know how to write a program that does what he's trying to do. I'm not doing his homework though.

Do you have a specific question?

getting closer
error LNK2019: unresolved external symbol "double __cdecl tri_area(double,double,double)" (?tri_area@@YANNNN@Z) referenced in function _main

#include <iostream>
#include <cmath>
using namespace std;
double tri_area(double,double,double);
int main(){
    double a,b,c,area;
    cout<<"Enter coefficients: ";
    cin>>a>>b>>c;
    area=tri_area(a,b,c);
    if(area<0)
        cout<<"There are no equal sides."<<endl;
    else
        cout<<"Area: "<<area<<endl;
    return 0;
}
double sdisc(double a,double b,double c){
    double s, t, area;
    s= (a + b + c)/2;
    t= s*(s-a)*(s-b)*(s-c);
    if(t<0)
        area=-1;
    else
        area=sqrt(t);
    return area;
}

Edited 3 Years Ago by Dani: Formatting fixed

double sdisc(double a,double b,double c){

Where did sdisc come in?

#include <iostream>
#include <cmath>
using namespace std;
double tri_area(double,double,double);
int main()
{
   double a,b,c,area;
   cout<<"Enter coefficients: ";
   cin>>a>>b>>c;
   area=tri_area(a,b,c);
   if ( area<0 )
      cout<<"There are no equal sides."<<endl;
   else
      cout<<"Area: "<<area<<endl;
   return 0;
}
double tri_area(double a,double b,double c)
{
   double s, t, area;
   s= (a + b + c)/2;
   t= s*(s-a)*(s-b)*(s-c);
   if ( t<0 )
      area=-1;
   else
      area=sqrt(t);
   return area;
}

/* my output
Enter coefficients: 3 4 5
Area: 6
*/
double sdisc(double a,double b,double c){

Where did sdisc come in?

#include <iostream>
#include <cmath>
using namespace std;
double tri_area(double,double,double);
int main()
{
   double a,b,c,area;
   cout<<"Enter coefficients: ";
   cin>>a>>b>>c;
   area=tri_area(a,b,c);
   if ( area<0 )
      cout<<"There are no equal sides."<<endl;
   else
      cout<<"Area: "<<area<<endl;
   return 0;
}
double tri_area(double a,double b,double c)
{
   double s, t, area;
   s= (a + b + c)/2;
   t= s*(s-a)*(s-b)*(s-c);
   if ( t<0 )
      area=-1;
   else
      area=sqrt(t);
   return area;
}

/* my output
Enter coefficients: 3 4 5
Area: 6
*/

sdisc was a mistake i made trying to put this problem together from a make of another problem. thanks for the help -its apreciated -and to the dude that thinks he is doing peoples homework for them- maybe ou should quit being involved on the internet-their are a lot of people who look for help -not for agrivation

You guys are really cool to help me out . i may not be as smart as you guys now but i'll catch up THanks

sdisc was a mistake i made trying to put this problem together from a make of another problem. thanks for the help -its apreciated -and to the dude that thinks he is doing peoples homework for them- maybe ou should quit being involved on the internet-their are a lot of people who look for help -not for agrivation

you was aggravated?

anyway, i think somehow emotions got involved and i think you missed it,

i was trying to help you, but doing it all for you isn't really helping you

i understand you feel a little defensive, that's cool, we all do that sometimes

i'm here to learn and help if i can and the offer still stands

do you have a specific question?

This question has already been answered. Start a new discussion instead.