Hi,
The following is an exercise in c++, I solved it but I doubt my solve is not right ..can someone tell me is my solve right or wrong especially the compiler didn't give me any errors
The exercise:
first look the attached image, The acceleration of a sleigh sliding down a hill is a = g sin a , where a is the slope of the hill, and the gravity acceleration g = 9.8 ms-2.
Write a C++ function that calculates the acceleration as a function of the slope a in degrees.
Hint: the header file MATH.H defines the common mathematical functions, including sin(x) (where x is in radians) and sqrt(x) (square root). The constant p is also defined in MATH.H with the name M_PI. To get access to these functions and constants, write:
#include <MATH.H>
My c++ code:
#include <math.h>
#include <iostream>
using namespace std;
int main()
{
double A=0;
double a=0;
double g=9.8;
const float PI=3.14159265;
double degAngle = sin(a*PI/180);
A = degAngle/9.8;
cout<<"acceleration is: "<< A <<endl;
return 0;
}