   c++ calculate acceleration from slope
  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 errorsThe 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; }   
  You need to do some work.First why didn't you use M_PI instead of writing PI out?Second how can acceleration answer be an angle?You don't even have the right units?Of course I would doubt your answer too if you don't even output the right units. As they say garbage in/garbage out so I don't see why you expect the compiler to help you out?;  This is the original excercise:http://www.eit.ihk-edu.dk/subjects/cpp/sleigh.html   ;Quote:Original post by iammfaThis is the original excercise:http://www.eit.ihk-edu.dk/subjects/cpp/sleigh.htmlRead the first sentence from the link you gave us and you will see whats wrong with your code.   