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

My code won\'t compile in c++ visual studio\'s i\'m not sure whats wrong exactly

ID: 2854487 • Letter: M

Question

My code won't compile in c++ visual studio's i'm not sure whats wrong exactly.

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

// here the function is used fro cheking
double equationRootB(double x, double y, double z)
{
return (-y + sqrt(y * y - 4 * x * z)) / (2 * x);
}

double equationRoot(double x, double y, double z)
{
double root;

asm(
"fldl %1 "
"fadd %%ST "
"fldl %1 "
"fldl %3 "
"fmulp %%ST(1) "
"fadd %%ST "
"fadd %%ST "
"fldl %2 "
"fldl %2 "
"fmulp %%ST(1) "
"fsubp %%ST(1) "
"fsqrt "
"fldl %2 "
"fchs "
"faddp %%ST(1) "
"fdivp %%ST(1) "
:"=t"(root)
:"m"(x), "m"(y), "m"(z)
);
return(root);
}

int main( char **argv,int argc)
{
double x, y, z;
double root, rootB;

if (argc != 4) {
printf("three arguments reuired: x, y, z ");
return -1;
}
x = atof(argv[1]);
y = atof(argv[2]);
z = atof(argv[3]);
root = equationRoot(x, y, z);
rootB = equationRootB(x, y, z);

printf("equationRoot(%.3f, %.3f, %.3f) = %.3f, %.3f ", x, y, z, root, rootB);

return 0;
}

Explanation / Answer

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

// here the function is used fro cheking
double equationRootB(double x, double y, double z)
{
return (-y + sqrt(y * y - 4 * x * z)) / (2 * x);
}

double equationRoot(double x, double y, double z)
{
double root;

asm(
"fldl %1 "
"fadd %%ST "
"fldl %1 "
"fldl %3 "
"fmulp %%ST(1) "
"fadd %%ST "
"fadd %%ST "
"fldl %2 "
"fldl %2 "
"fmulp %%ST(1) "
"fsubp %%ST(1) "
"fsqrt "
"fldl %2 "
"fchs "
"faddp %%ST(1) "
"fdivp %%ST(1) "
:"=t"(root)
:"m"(x), "m"(y), "m"(z)
);
return(root);
}

int main( 'char **'argv,int argc)
{
double x, y, z;
double root, rootB;

if (argc != 4) {
printf("three arguments reuired: x, y, z ");
return -1;
}
x = atof(argv[1]);
y = atof(argv[2]);
z = atof(argv[3]);
root = equationRoot(x, y, z);
rootB = equationRootB(x, y, z);

printf("equationRoot(%.3f, %.3f, %.3f) = %.3f, %.3f ", x, y, z, root, rootB);

return 0;
}

Hire Me For All Your Tutoring Needs
Integrity-first tutoring: clear explanations, guidance, and feedback.
Drop an Email at
drjack9650@gmail.com
Chat Now And Get Quote