Question: public class ImpPythTripEx public static double[][] triples = new double[3][3]; public static void inputTwoSides(double sideAIn, double sideBIn, int rowIndex) { triples[rowIndex][0] = sideAIn; triples[rowIndex][1] =

public class ImpPythTripEx

public static double[][] triples = new double[3][3];

public static void inputTwoSides(double sideAIn, double sideBIn, int rowIndex) { triples[rowIndex][0] = sideAIn;

triples[rowIndex][1] = sideBIn;

triples[rowIndex][2] = Math.sqrt(Math.pow(sideAIn, 2) + Math.pow(sideBIn, 2));

}

public static void inputOneSideAndHyp(double sideAIn, double hypIn, int rowIndex) { triples[rowIndex][0] = sideAIn;

triples[rowIndex][2] = hypIn;

triples[rowIndex][1] = Math.sqrt(Math.pow(hypIn,2) - Math.pow(sideAIn, 2));

}

public static void printTriple() {

for(int i=0; i<3; i++) {

System.out.print("PythTriple [ ");

for(int j=0; j<3; j++) {

if(j==0) {

System.out.print("sideA=");

}

if(j==1)

{ System.out.print("sideB=");

}

if(j==2)

{ System.out.print("hyp=");

}

System.out.print(String.format("%5.3f",triples[i][j]) + " ");

}

System.out.println("]"); } }

public static void main(String[] args) {

inputOneSideAndHyp(3,5,0);

inputOneSideAndHyp(1, Math.sqrt(2),1);

inputTwoSides(2, 3, 2);

printTriple();

}}

1.) Write a new version of the imperative programming exercise (involving Pythagorean Triples) in C, with alterations that include

using an array of instances of a Pythagorean Triple struct instead of a two dimensional array

make sure the array is on the heap. Be sure to use the malloc function

***Please include screenshots of both the input and output! Thank you :)***

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!