Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- typedef struct
- {
- float w;
- int h;
- }box;
- box sum(box a1,box a2);
- float sumcal(int a1,int a2,float b1,float b2);
- float sumcalbox(box a1,box a2);
- int main()
- {
- box box1,box2;
- printf("Weigth 1 : ");
- scanf("%f",&box1.w);
- printf("Higth 1 : ");
- scanf("%d",&box1.h);
- printf("\n");
- printf("Weigth 2 : ");
- scanf("%f",&box2.w);
- printf("Higth 2 : ");
- scanf("%d",&box2.h);
- printf("\n");
- box result=sum(box1,box2);
- printf("Hight = %d\nWeight = %.2f\n",result.h,result.w);
- printf("Allsum = %.2f\n",sumcal(box2.h,box1.h,box1.w,box2.w));
- printf("Allsum = %.2f\n",sumcalbox(box1,box2));
- return 0;
- }
- box sum(box a1,box a2)
- {
- box c;
- c.h=(a1.h+a2.h);
- c.w=(a1.w+a2.w);
- return c;
- }
- float sumcal(int a1,int a2,float b1,float b2)
- {
- return a1+a2+b1+b2;
- }
- float sumcalbox(box a1,box a2)
- {
- return a1.w+a1.h+a2.w+a2.h;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement