Best Answer

To calculate the area of a triangle you need

  1. to get the coordinates of the points of the triangles A = (xa, ya), etc (into a structure, eg user input and parsing, direct assignment in the program, etc)
  2. calculate area = abs( (xb*ya - xa*yb) + (xc*yb - xb*yc) + (xa*yc - xc*ya) ) / 2
  3. put the answer somewhere (eg onto stdout, in the struct for future use, etc).

Your structure would include (at a minimum) the coordinates of the points, eg:

struct triangle


int xa, ya;

int xb, yb;

int xc, yc;


then you would declare a structure to hold the points and use it to calculate the area, eg:

struct triangle t1;

t1.xa = 0; t1.ya = 0;

t1.xb = 5; t1.yb = 5;

t1,xc = 7; t1.yc = 7;

area = calculate_area(&t1);

To calculate the area, you could put it into a function:


struct triangle *tru;



area = ()abs( (tri->xb * tri->ya - tri->xa * ... )) /* formula above */

return area;


I'll let you think about:

  1. what the return type ought to be;
  2. what type to use to store the triangle's points;
  3. any potential error trapping that may need to be done;
  4. what compiler options (and header files) you may need.

and put the program together.

Exactly what data you want to store in the struct (minimum the points, but you may want to store the area of the triangle as well - in future you could expand to include calculating the side lengths and angles)

User Avatar

Wiki User

12y ago
This answer is:
User Avatar

Add your answer:

Earn +20 pts
Q: How do you write a program in C that calculates the area of a triangle given the three x and y coordinates of each corner of the triangle Alongside it must make use of structs.?
Write your answer...
Still have questions?
magnify glass
Continue Learning about Math & Arithmetic

Using a computer how do you create a program that calculates the circumference and area of a circle?

a circle has an area of 36pie square centimeters what is the circumference ?

For loop program turbo c making a right triangle?


How many numbers were in pascals triangle?

There is actually no limit to the number of numbers in Pascal's Triangle. The triangle is simply a way to remember the coefficients of the product of two binomials (or the expansion of a binomial raised to a power). See the link below. The triangle starts like this: 1 1 1 1 2 1 1 3 3 1 1 4 6 4 1 It goes on forever. Simply begin and end each row with a one and find the numbers in the middle by adding the two above it. Edit: I don't know how to make the above triangle look correct here. The program wants to remove all of the spaces, making the triangle look like a right triangle. Just ignore that. It should look like a pyramid, with the top 1 in the center.

How do you find area of a triangle given its 3 sides in c program?

#include<stdio.h> #include<math.h> main() { float A,a,b,c,s; printf("entr the value of a,b and c"); scanf("%f %f %f",&a,&b,&c); A=sqrt(s*s-a*s-b*s-c) printf("area of the triangle %f\n"A); getch(); }

Write a program to print a right angle triangle containing digit in java?

let s1,s2,s3 be three sides of a triangle.import java.lang.*;import*;import java.util.*;class Triangle{public static void main(String args[]){boolean test=false;int s1,s2,s3;Scanner input = new Scanner(;System.out.println("enter the side1 of triangle");s1=input.nextInt();System.out.println("enter the side2 of triangle");s2=input.nextInt();System.out.println("enter the side3 of triangle");s3=input.nextInt();if((s1*s1)==(s2*s2)+(s3*s3)){test=true;}else if((s2*s2)==(s1*s1)+(s3*s3)){test=true;}else if((s3*s3)==(s1*s1)+(s2*s2)){test=true;}if(test==true)System.out.println("Entered sides form a right angle triangle.....");elseSystem.out.println("Entered sides dosn't form a right angle triangle.....");}}

Related questions

How do you write a qbasic program to find area and circumerence of a circle?

Write a program that calculates the area of a triangle in QBASIC

What are the answers for Programming logic and design chapter 6?

program calculates

How do you write a c program which calculates the value of money at the end of each year of investment? the value of money

Using while loop write a program which calculates the product of digits from 1 to 5 and also show these nos vertically?

Using while loop, write a program which calculates the product of digits from 1 to 5 and also show these no's vertically.

Is a program with no input an incorrect program?

No, as long as it calculates something, displays something, or otherwise has an output that benefits the user, it is a program. It could be a program that makes a random number, or a program that tells the user a joke from a database.

When coordinates going into a program are specified relative to the program zero point it is called?


What is a computer program that coordinates all the activities of a computer hardware?

An operating system coordinates the activities of computer hardware

What program coordinates activities of computer hardware?

Operating system

Was there a program called the triangle?


How do you write a program that calculates the sum of the matrix elements given numbers?

ring me and ill explain - 086 22222222222222227 ring me

Using a computer how do you create a program that calculates the circumference and area of a circle?

a circle has an area of 36pie square centimeters what is the circumference ?

What does the computer program Md5sum do?

Md5sum is a program that verifies and calculates 128-bit MD5 hashes. The MD5 checksum is seen as the compact digital fingerprint that is unique to each file.