why dosnt work this program

+2 leo interisti · January 18, 2015
#include<iostream>
#include<math.h>
using namespace std;
int main()
{
    int a,b,c,area,d,s,sqrt,R,r;
    cin>>a>>b>>c;
    s=(a+b+c)/2;
d=s*(s-a)*(s-b)*(s-c);
    if(d>0){
             area=sqrt(d);
             R=(a*b*c)/(4*area);
             r=area/s;
             cout<<d<<area<<R<<r;
 else if(d<=0)cout<<wrong data;

}
    return 0;
}

Post a Reply

Replies

Oldest  Newest  Rating
+1 c student · January 18, 2015
math.h header is not c++
you'll get incorrect values when dividing with ints
your if statement is incorrectly closed
your cout statement is incorrect

seems like you're having trouble with the most trivial of tasks of writing the code and debugging it.  maybe you should refer to better source of information?
+4 Sheldon Juncker · January 18, 2015
You must post code in a code block!

#include<iostream>
#include<math.h>
using namespace std;

int main()
{
   int a,b,c,area,d,s,sqrt,R,r;
   cin>>a>>b>>c;
   s=(a+b+c)/2;
   d=s*(s-a)*(s-b)*(s-c);

   if(d>0)
   {
       area=sqrt(d);
       R=(a*b*c)/(4*area);
       r=area/s;
       cout<<d<<area<<R<<r;
       else if(d<=0)cout<<wrong data;

   }

   return 0;
}


You're welcome. :)
+1 Bernard Pyc0d333 Parah · January 19, 2015
and I Suggest you use

#include <cmath>


instead of math.h
  • 1

C++

107,111 followers
About

Used in many types of software including music players, video games, and many large scale applications.

Links
Moderators
Bucky Roberts Administrator