Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

In hullSpeed(), write FPU assembly code to calculate the \"hull speed\" of a boa

ID: 3757756 • Letter: I

Question

In hullSpeed(), write FPU assembly code to calculate the "hull speed" of a boat
according to the formula 1.34*sqrt(lgth) where lgth is the length in feet of the
boat at the waterline, and the computed speed is specified in knots. How do we write on the double hullSpeed() in C to run this file?

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

double hullSpeed(double lgth)
{

   return 0.0;
}

double hullSpeedC(double lgth)
{

   return 1.34 * sqrt(lgth);
}

int main (int argc, char **argv)
{
   double   lgth;
   double   hullSpd, hullSpdC;

   if (argc != 2) {
       printf("need 1 argument: boat length ");
       return -1;
       }
   lgth = atof(argv[1]);
   hullSpd = hullSpeed(lgth);
   hullSpdC = hullSpeedC(lgth);

   printf("hullSpeed(%.0f) = %.3f, %.3f ", lgth, hullSpd, hullSpdC);

   return 0;
}

Explanation / Answer

This program i.e. your program is running excellently but with one modification.

1) in the hullspeed(lgth) function you never used lgth, you can use that.

2) Make exe file of this program and run the file in the following way.

At the prompt you give the exe file name and one value i.e. boat length

followed by a space. Then this file will run.

#include <stdio.h>
#include <stdlib.h>
#include <math.h>
double hullSpeed(double lgth)
{
return 0.0;
}
double hullSpeedC(double lgth)
{
return 1.34 * sqrt(lgth);
}
int main (int argc, char **argv)
{
double lgth;
double hullSpd, hullSpdC;
if (argc != 2) {
printf("need 1 argument: boat length ");
return -1;
}
lgth = atof(argv[1]);
hullSpd = hullSpeed(lgth);
hullSpdC = hullSpeedC(lgth);
printf("hullSpeed(%.0f) = %.3f, %.3f ", lgth, hullSpd, hullSpdC);
return 0;
}