Advertisement
Sierra_ONE

How Big Is Your Slice?

Oct 8th, 2023
54
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.97 KB | Source Code | 0 0
  1. /*
  2. 3. How Big Is Your Slice?
  3. Me and my roommate have been fighting for over an hour about who has the bigger pizza slice. He thinks that mine is bigger, but I think he's just saying that so he can't give up his slice, which is obviously bigger!
  4.  
  5.  
  6.  
  7. However, since we are educated gentlemen, we have decided to let math decide for us. I'm going to give you two measurements: base and height. Using these two measurements, determine the area of our triangular pizza slices and end this feud once and for all!
  8.  
  9. Note: Area of a triangle = (base x height) / 2
  10.  
  11. Inputs
  12.  
  13. 1. The base of the pizza slize
  14.  
  15. 2. The height of the pizza slice
  16. */
  17.  
  18. #include <stdio.h>
  19.  
  20. int main (void){
  21.     float base, height, area;
  22.  
  23.     printf("Enter the base of the pizza slice: ");
  24.     scanf("%f", &base);
  25.     printf("Enter the height of the pizza slice: ");
  26.     scanf("%f", &height);
  27.  
  28.     area = (base * height) / 2;
  29.  
  30.     printf("Area of the pizza slice = %.2f", area);
  31.  
  32.  
  33.  
  34.  
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement