fork download
  1. #include<stdio.h>
  2.  
  3. float input(char*c){
  4. float x;
  5. printf("%s",c);
  6. scanf("%f",&x);
  7. return x;
  8. }
  9. float calcs(float v,float h){
  10. float s;
  11. s=v*h;
  12. return s;
  13. }
  14. float calcl(float v,float h){
  15. float l;
  16. l=2*(v+h);
  17. return l;
  18. }
  19. void output(char*c,float x){
  20. printf("%s%f\n",c,x);
  21. return;
  22. }
  23. int main(){
  24. float v,h,s,l;
  25. v=input("縦の長さは\n");
  26. h=input("横の長さは\n");
  27. s=calcs(v,h);
  28. l=calcl(v,h);
  29. output("面積は",s);
  30. output("周の長さは",l);
  31. return 0;
  32. }
Success #stdin #stdout 0s 5520KB
stdin
3
4
stdout
縦の長さは
横の長さは
面積は12.000000
周の長さは14.000000