Best Answer

To calculate the area of a triangle you need

- 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)
- calculate area = abs( (xb*ya - xa*yb) + (xc*yb - xb*yc) + (xa*yc - xc*ya) ) / 2
- 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 = (

return area;

}

I'll let you think about:

- what the return type ought to be;
- what type to use to store the triangle's points;
- any potential error trapping that may need to be done;
- 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)

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...

Submit

Still have questions?

Continue Learning about Math & Arithmetic

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

yes

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.

#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(); }

let s1,s2,s3 be three sides of a triangle.import java.lang.*;import java.io.*;import java.util.*;class Triangle{public static void main(String args[]){boolean test=false;int s1,s2,s3;Scanner input = new Scanner(System.in);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

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

program calculates

Reference:cprogramming-bd.com/c_page3.aspx#calculates the value of money

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

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.

rapid

An operating system coordinates the activities of computer hardware

Operating system

yea

ring me and ill explain - 086 22222222222222227 ring me

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

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.