# Thread: Helping out a friend...

1. Originally Posted by rhymewithnothin
Loko, you fixed it again. We're nearing the end, 5 more errors, and I may be able to get some of them myself.

Next one....

"called object is not a function" referring to
Code:
```		 areaTri = (1/2)(baseTri*heightTri);   //This is casting (baseTri*heightTri) to (1/2) which is obviously not correct  :D .

this should be  areaTri = (1/2) * (baseTri*heightTri);   thats if your trying to multiply 1/2 with the product of  baseTri*heightTri).```
This would be my last reply i gtg somewhere.

peace

2. Originally Posted by jcarouth
Code:
`areaTri = (double)(1/2)*(baseTri*heightTri);`
I didn't read where you declared areaTri, but I assumed it is of type double.
That still won't make 1/2 evaluate to 0.5. See my above post.

3. Thank you very much. When I compile and link now all the error messages are gone. Thanks again. I'll check back if I need more help.

4. OK all the erros are gone, but when I try to run the I/O, it will ask me what shape I want to find the area of, and when I type what I want, it just ends the program. Here is the completed code if someone wants to put it in their compiler and try to figure it out...

Code:
```/*This program will compute the area of a rectangle,                        */
/*triangle, circle, ellipse, and sphere.                                    */

#include <stdio.h>
#include <math.h>
#define PI 3.141593

int main(void)
{
/* Declare first variable. */

char shape, rectangle, triangle, circle, ellipse, sphere;

/* Determine which shape to find the area of */

printf("Find the area of a rectangle, triangle, circle, ellipse, or sphere?");
scanf("%c",&shape);

if (shape == rectangle){
/* Declare set of variables for this shape */

float lengthRect, widthRect, areaRect;
printf("Enter the length. \n");
scanf("%lf",&lengthRect);
printf("Enter the width. \n");
scanf("%lf",&widthRect);

/* Compute the area */

areaRect = (lengthRect*widthRect);
printf("The area of the rectangle is "
"%5.2lf \n",areaRect);
}
else if (shape == triangle){
/* Declare set of variables for this shape */

float baseTri, heightTri, areaTri;
printf("Enter the base. \n");
scanf("%lf",&baseTri);
printf("Enter the height. \n");
scanf("%lf",&heightTri);

/* Compute the area */

areaTri = (.5)*(baseTri*heightTri);
printf("The area of the triangle is "
"%5.2lf \n",areaTri);
}
else if (shape == circle){
/* Declare set of variables for this shape */

/* Compute the area */

printf("The area of the circle is "
"%5.2lf \n",areaCirc);
}
else if (shape == ellipse){
/* Declare set of variables for this shape */

float semiaxisA, semiaxisB, areaEllipse;
printf("Enter the length of semiaxisA. \n");
scanf("%lf",&semiaxisA);
printf("Enter the length of semiaxisB. \n");
scanf("%lf",&semiaxisB);

/* Compute the area */

areaEllipse = (PI*semiaxisA*semiaxisB);
printf("The area of the ellipse is "
"%5.2lf \n",areaEllipse);
}
else if (shape == sphere){
/* Declare set of variables for this shape */

printf("Enter the length of the radius. \n");

/* Compute the area */

printf("The surface area of the sphere is "
"%5.2lf \n",areaSphere);
}
return 0;
}```
Thanks again.

5. Originally Posted by cwr
That still won't make 1/2 evaluate to 0.5. See my above post.

meant to be ((double)(1)/2)....sorry

6. Code:
```/*This program will compute the area of a rectangle,                        */
/*triangle, circle, ellipse, and sphere.                                    */

#include <stdio.h>
#include <math.h>
#define PI 3.141593

int main(void)
{
/* Declare first variable. */

char shape;
//char shape, rectangle, triangle, circle, ellipse, sphere;

/* Determine which shape to find the area of */

printf("Find the area of a rectangle, triangle, circle, ellipse, or sphere?");
scanf("%c",&shape);

if (shape == 'r'){
/* Declare set of variables for this shape */

float lengthRect, widthRect, areaRect;
printf("Enter the length. \n");
scanf("%lf",&lengthRect);
printf("Enter the width. \n");
scanf("%lf",&widthRect);

/* Compute the area */

areaRect = (lengthRect*widthRect);
printf("The area of the rectangle is "
"%5.2lf \n",areaRect);
}
else if (shape == 't'){
/* Declare set of variables for this shape */

float baseTri, heightTri, areaTri;
printf("Enter the base. \n");
scanf("%lf",&baseTri);
printf("Enter the height. \n");
scanf("%lf",&heightTri);

/* Compute the area */

areaTri = (.5)*(baseTri*heightTri);
printf("The area of the triangle is "
"%5.2lf \n",areaTri);
}
else if (shape == 'c'){
/* Declare set of variables for this shape */

/* Compute the area */

printf("The area of the circle is "
"%5.2lf \n",areaCirc);
}
else if (shape == 'e'){
/* Declare set of variables for this shape */

float semiaxisA, semiaxisB, areaEllipse;
printf("Enter the length of semiaxisA. \n");
scanf("%lf",&semiaxisA);
printf("Enter the length of semiaxisB. \n");
scanf("%lf",&semiaxisB);

/* Compute the area */

areaEllipse = (PI*semiaxisA*semiaxisB);
printf("The area of the ellipse is "
"%5.2lf \n",areaEllipse);
}
else if (shape == 's'){
/* Declare set of variables for this shape */

printf("Enter the length of the radius. \n");

/* Compute the area */