TizzyT

Something for Stephen -TizzyT

May 28th, 2015
141
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. void getData (double*,double*);
  5. void printRes(double,double);
  6. void printSer(double,double);
  7. void AreaPerimeter(double,double);
  8.  
  9. int main (void){
  10.     double a = 0, b = 0;
  11.     getData (&a, &b);
  12.     printRes(a, b);
  13.     printSer(b, a);
  14.     AreaPerimeter(a, b);
  15. }
  16.  
  17. void getData (double *a, double *b){
  18.     printf("Please enter two integer numbers: ");
  19.     scanf("%lf %lf", a, b);
  20. }
  21.  
  22. void printRes (double a, double b){
  23.     printf("%lf %lf\n", a, b);
  24. }
  25.  
  26. void printSer (double b, double a){
  27.     printf("%lf %lf\n", b, a);
  28. }
  29.  
  30. void AreaPerimeter (int a, int b){
  31.     double hypotenuse = sqrt(pow(a,2) + pow(b,2));
  32.     printf("The perimeter of a right triangle with a base of %d, a height of %d and a hypotenuse of %lf is %lf.\n\n"
  33.                "The area of a right triangle with base %d and height %d is %.2lf.\n", a, b, hypotenuse, (double)(a + b) + hypotenuse, a, b, (double)(a * b)/2);
  34. }
Advertisement
Add Comment
Please, Sign In to add comment