Take two argument of type double and return the hypotenuse as a double.
/*
title: hypotenuseCalculation
author: aeriqusyairi
date: Jan23 2012
*/
#include<stdio.h>
#include<math.h>
double hypotenuse(double, double);
int main(){
double firstSide = 0, secondSide = 0, hypo = 0;
printf("Enter the side of a right triangle\nto calculate its corresponding hypotenuse...\n");
printf("Side 1:");
scanf("%lf", &firstSide);
printf("Side 2:");
scanf("%lf", &secondSide);
hypo = hypotenuse(firstSide, secondSide);
printf("The hypotenuse of a right triangle with %.2lf and %.2lf\nas the other 2 side is %.2lf\n",
firstSide, secondSide, hypo);
system("pause");
return 0;
}
double hypotenuse(double a, double b){
double c;
return sqrt((a * a) + (b * b));
}
No comments:
Post a Comment