Write a c++ program that calculates the slope of ramp using the equation a2 + b2 = c2 where a is the height of the ramp b is the width of the ramp and c is the slope of the ramp. The program should accept the height and width and calculate and print the slope of the ramp
#include <iostream>
#include <cmath>
using namespace std;
int main()
{
double a, b, c;
cout << "Enter width of the ramp: ";
cin >> a;
cout << "Enter height of the ramp: ";
cin >> b;
c = sqrt(a * a + b * b);
cout << "The slope of the ramp is: " << c << endl;
system("pause");
return 0;
}
Comments
Leave a comment