/* June 08, 1998 */
/* Program to compute the area of triangle or square using pointers*/
#include
#include
/* function definition */
void area_triangle (double tbase, double theight, double *tareap);
void area_square (double sside, double *sareap);
main ()
{
/* declarations */
double side, base, height, tarea, sarea;
char type;
/* Request for type */
printf("Enter S for Square or T for Triangle> ");
scanf("%c", &type);
/* condition statements */
if (type == 'T' || type == 't')
{
/* Get input */
printf("Input the length of the base of the triangle> ");
scanf("%lf", &base);
printf("Input the length of the height of the triangle> ");
scanf("%lf", &height);
area_triangle(base, height, &tarea);
/* display area of triangle */
printf("The area of the triangle is %.2f\n", tarea);
}
else
{
/* Get input */
printf("Input the length of the side of the square> ");
scanf("%lf", &side);
area_square(side, &sarea);
/* display area of square */
printf("Area of the square is %.2f\n", sarea);
}
}
/* function definition */
void
area_triangle(double tbase, double theight, double *tareap)
{
/* compute area of triangle */
*tareap = 0.5 * (tbase) * (theight);
}
void
area_square(double sside, double *sareap)
{
/* compute area of square */
*sareap = (sside) * (sside);
}
               (
geocities.com/yosemite/rapids)                   (
geocities.com/yosemite)