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

Programming Floating-Point Arithmetic Implement functions that perform calculati

ID: 3574487 • Letter: P

Question

Programming Floating-Point Arithmetic

Implement functions that perform calculation according to the tasks given below. All input and output variables must be of floating-point type (C/C++ float or double). Find correct formulas by yourself and define the required parameters and types in order to compute the result.

Note: Calculations, conditions and jumps may be implemented with Inline Assembler!

Task for grade level 6: Calculate the area of parallelogram then the length of sides and angle between them is given.

Task for grade level 8: Calculate the surface area of cone when base radius and height is given.

Please use template below for the solutions;

#include "stdafx.h"

#include

#include

// For each grade level variant implement own function, e.g.:

double solution_for_grade_X(double a, double b, double c)

{

    double r;

    __asm

    {

        // Your Inline Assembler instructions for grade level X go here

        // :::

       fst QWORD PTR [r]    ; r = st(0)

    }

    return r; // Please note that in assembler module the result must be placed in st(0)!

}

int main()

{

    // Change the parameters according to your grade level function, e.g.:

    double r = solution_for_grade_X(1.5, 2.3, 5.6);

    // Print the result vector to the console:

    _tprintf(_T("%d "), r);

    // :::

    return 0;

}

Explanation / Answer

1)Area of parallelogram

#include<iostream>
#include<cmath>
using namespace std;
double areaparallel(double a, double b,float theta)
{
return(a*b*sin(theta));
}
int main()
{
double a,b;
float theta;
   cout<<"Enter sides of parallellogram a and b";
   cin>>a>>b;
   cout<<"Enter theta value:";
   cin>>theta;
double area = areaparallel(a,b,theta);
// Print the result vector to the console:
cout<<"area of the parallelogram with sides "<<a<<" and "<<b<<"and angle "<<theta<<" is "<<area;
return 0;
}

2)C++ program to find area of the surface of the cone

#include<iostream>
#include<cmath>
using namespace std;
double areacone(double r, double h)
{
double a=sqrt(h*h+r*r);
       double s=(3.14*r)*(r+a);
       return s;
}
int main()
{
double r,h;
   cout<<"Enter radius and height of the cone ";
   cin>>r>>h;
double area = areacone(r,h);
// Print the result vector to the console:
cout<<"Surface area of the cone "<<r<<" and "<<h<<" is "<<area;
return 0;
}