daily pastebin goal
96%
SHARE
TWEET

Untitled

clayy24 Sep 14th, 2018 50 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  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. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top