C PROGRAMMING   Instructions: Edit the code below to meet the criteria of the following steps:        Step 1) Enter the lengths of the sides directly into the structure using a structure pointer and the  "->" operator.      Step 2) Create a new function, and calculate the perimeter and area of the triangle within it. Pass the triangle                   structure to the function by reference using the structure pointer.      Step 3) In the main( ) function, print the perimeter and area directly from the triangle structure to the console.                   Use the structure pointer and "->" operator in the call to printf( ). __________________________________________________________________________________________ #include #include #include struct calculate {     float a, b, c, perimeter, area; }; int main() {     struct calculate tri;          printf("Enter Side Lengths of a Triangle: \n");          scanf("%f\n", &tri.a);     scanf("%f\n", &tri.b);     scanf("%f\n", &tri.c);     tri.perimeter = (tri.a + tri.b + tri.c) / 2;     tri.area = sqrt(tri.perimeter * (tri.perimeter - tri.a) * (tri.perimeter - tri.b) * (tri.perimeter - tri.c));          printf("Semiperimeter = %f\n", tri.perimeter);     printf("Area = %f\n", tri.area);     return 1; }

Computer Networking: A Top-Down Approach (7th Edition)
7th Edition
ISBN:9780133594140
Author:James Kurose, Keith Ross
Publisher:James Kurose, Keith Ross
Chapter1: Computer Networks And The Internet
Section: Chapter Questions
Problem R1RQ: What is the difference between a host and an end system? List several different types of end...
icon
Related questions
Question

C PROGRAMMING

 

Instructions: Edit the code below to meet the criteria of the following steps:

 

     Step 1) Enter the lengths of the sides directly into the structure using a structure pointer and the  "->" operator.

     Step 2) Create a new function, and calculate the perimeter and area of the triangle within it. Pass the triangle

                  structure to the function by reference using the structure pointer.

     Step 3) In the main( ) function, print the perimeter and area directly from the triangle structure to the console.

                  Use the structure pointer and "->" operator in the call to printf( ).

__________________________________________________________________________________________

#include <stdio.h>
#include <stdlib.h>
#include <math.h>

struct calculate
{
    float a, b, c, perimeter, area;
};

int main()
{
    struct calculate tri;
    
    printf("Enter Side Lengths of a Triangle: \n");
    
    scanf("%f\n", &tri.a);
    scanf("%f\n", &tri.b);
    scanf("%f\n", &tri.c);

    tri.perimeter = (tri.a + tri.b + tri.c) / 2;

    tri.area = sqrt(tri.perimeter * (tri.perimeter - tri.a) * (tri.perimeter - tri.b) * (tri.perimeter - tri.c));
    
    printf("Semiperimeter = %f\n", tri.perimeter);
    printf("Area = %f\n", tri.area);

    return 1;
}

Expert Solution
steps

Step by step

Solved in 2 steps

Blurred answer
Similar questions
  • SEE MORE QUESTIONS
Recommended textbooks for you
Computer Networking: A Top-Down Approach (7th Edi…
Computer Networking: A Top-Down Approach (7th Edi…
Computer Engineering
ISBN:
9780133594140
Author:
James Kurose, Keith Ross
Publisher:
PEARSON
Computer Organization and Design MIPS Edition, Fi…
Computer Organization and Design MIPS Edition, Fi…
Computer Engineering
ISBN:
9780124077263
Author:
David A. Patterson, John L. Hennessy
Publisher:
Elsevier Science
Network+ Guide to Networks (MindTap Course List)
Network+ Guide to Networks (MindTap Course List)
Computer Engineering
ISBN:
9781337569330
Author:
Jill West, Tamara Dean, Jean Andrews
Publisher:
Cengage Learning
Concepts of Database Management
Concepts of Database Management
Computer Engineering
ISBN:
9781337093422
Author:
Joy L. Starks, Philip J. Pratt, Mary Z. Last
Publisher:
Cengage Learning
Prelude to Programming
Prelude to Programming
Computer Engineering
ISBN:
9780133750423
Author:
VENIT, Stewart
Publisher:
Pearson Education
Sc Business Data Communications and Networking, T…
Sc Business Data Communications and Networking, T…
Computer Engineering
ISBN:
9781119368830
Author:
FITZGERALD
Publisher:
WILEY