Advertisement
Theerayut

box

Nov 28th, 2016
82
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.88 KB | None | 0 0
  1. #include <stdio.h>
  2. typedef struct
  3. {
  4.     float w;
  5.     int h;
  6. }box;
  7.     box sum(box a1,box a2);
  8.     float sumcal(int a1,int a2,float b1,float b2);
  9.     float sumcalbox(box a1,box a2);
  10. int main()
  11. {  
  12.     box box1,box2;
  13.     printf("Weigth 1 : ");
  14.     scanf("%f",&box1.w);
  15.     printf("Higth 1 : ");
  16.     scanf("%d",&box1.h);
  17.     printf("\n");
  18.     printf("Weigth 2 : ");
  19.     scanf("%f",&box2.w);
  20.     printf("Higth 2 : ");
  21.     scanf("%d",&box2.h);
  22.     printf("\n");
  23.     box result=sum(box1,box2);
  24.     printf("Hight = %d\nWeight = %.2f\n",result.h,result.w);
  25.     printf("Allsum = %.2f\n",sumcal(box2.h,box1.h,box1.w,box2.w));
  26.     printf("Allsum = %.2f\n",sumcalbox(box1,box2));
  27.     return 0;
  28. }
  29.  
  30.     box sum(box a1,box a2)
  31.     {
  32.         box c;
  33.         c.h=(a1.h+a2.h);
  34.         c.w=(a1.w+a2.w);
  35.         return c;
  36.     }
  37.     float sumcal(int a1,int a2,float b1,float b2)
  38.     {
  39.         return a1+a2+b1+b2;
  40.     }
  41.     float sumcalbox(box a1,box a2)
  42.     {
  43.         return  a1.w+a1.h+a2.w+a2.h;
  44.     }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement