Advertisement
clayy24

Untitled

Sep 14th, 2018
99
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.72 KB | None | 0 0
  1. //
  2. // main.c
  3. // Lab4
  4. //
  5. // Created by on 9/14/18.
  6. // Copyright © 2018 . All rights reserved.
  7. //
  8.  
  9. #include <stdio.h>
  10.  
  11. int main()
  12. {
  13. //declare variables
  14. float width, length, perimeter, area;
  15.  
  16. //prompt user and collect user data
  17. printf("Width: ");
  18. scanf("%f", &width);
  19. printf("Length: ");
  20. scanf("%f", &length);
  21.  
  22. //perform calculations
  23. perimeter = 2 * width + 2 * length;
  24. area = width * length;
  25.  
  26. //display results to screen
  27. printf("\n%15s %15s %15s %15s\n", "length", "width", "perimeter", "area");
  28. printf("%15.2f ", length);
  29. printf("%15.2f ", width);
  30. printf("%15.2f ", perimeter);
  31. printf("%15.2f \n", area);
  32.  
  33. return 0;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement