Answered step by step
Verified Expert Solution
Link Copied!

Question

1 Approved Answer

Hello all, This code is written in C programming. I was looking for some help. I need to manipulate this script so it becomes a

Hello all,

This code is written in C programming. I was looking for some help.

I need to manipulate this script so it becomes a user defined function that does not take any argument and does not return any value.

#include #include

float S, trianglearea; float a[6],A,B,C; float triangle(float arr[]); main() { printf("What is the X coordinate of the first verticie? "); scanf("%f",&a[0]);

printf("What is the Y coordinate of the first verticie? "); scanf("%f",&a[1]);

printf("What is the X coordinate of the second verticie? "); scanf("%f",&a[2]);

printf("What is the Y coordinate of the second verticie? "); scanf("%f",&a[3]);

printf("What is the X coordinate of the third verticie? "); scanf("%f",&a[4]);

printf("What is the Y coordinate of the third verticie? "); scanf("%f",&a[5]);

triangle(a); printf("The area of a triangle with verticies (%5.2f, %5.2f),(%5.2f,%5.2f),(%5.2f,%5.2f), is %5.2f. ",a[0],a[1],a[2],a[3],a[4],a[5],trianglearea);

getchar(); return 0; }

float triangle (float a[]){ A=sqrt((a[0]-a[2])*(a[0]-a[2])+(a[1]-a[3])*(a[1]-a[3])); B=sqrt((a[0]-a[4])*(a[0]-a[4])+(a[1]-a[5])*(a[1]-a[5])); C=sqrt((a[2]-a[4])*(a[2]-a[4])+(a[3]-a[5])*(a[3]-a[5])); trianglearea=pow(S*(S-A)*(S-B)*(S-C),.5); return trianglearea; }

Step by Step Solution

There are 3 Steps involved in it

Step: 1

blur-text-image

Get Instant Access to Expert-Tailored Solutions

See step-by-step solutions with expert insights and AI powered tools for academic success

Step: 2

blur-text-image_2

Step: 3

blur-text-image_3

Ace Your Homework with AI

Get the answers you need in no time with our AI-driven, step-by-step assistance

Get Started

Recommended Textbook for

Graph Databases In Action

Authors: Dave Bechberger, Josh Perryman

1st Edition

1617296376, 978-1617296376

More Books

Students also viewed these Databases questions

Question

Identify five strategies to prevent workplace bullying.

Answered: 1 week ago