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 m/s2.
a) write a c++ function that calculates the acceleration as a function of the slope a in degrees.
b)write a c++ program that reads the slope and length of the hill as inputs,and calculates how long time it takes to slide down the hill.
1
Expert's answer
2012-07-17T09:14:17-0400
a) write a c++ function that calculates the acceleration as a function of the slope a in degrees.
double acc(double a){ return 9.8*sin(a); }
b)write a c++ program that reads the slope and length of the hill as inputs, and calculates how long time it takes to slide down the hill.
double time(double a, double l){ return sqrt(2*l/a); }
void main(){ cout<<"Enter the length of the hill (in meters): "; cin>>l; cout<<"Enter the slope of the hill (in degrees): "; cin>>a; cout<<"It takes "<<time(a, l)<< " seconds to slide down the hill.\r\n"; getch(); }
Comments
Leave a comment