Advertisement
Aminpro

[ECP1016] In-Lab Assignment Trimester 2 2012 Number 1

Nov 28th, 2012
458
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.90 KB | None | 0 0
  1. #include <stdio.h>
  2. #include <math.h>
  3.  
  4. //Aminpro
  5. //https://www.facebook.com/AminproPastebin
  6.  
  7. int main(void)
  8. {
  9.     float r = 0.00;
  10.     float volume = 0.00;
  11.     float total = 0.00;
  12.     float h = 0.00;
  13.  
  14.    while (r != 999 && h != 999){
  15. // Thanks Ah Slevin, for pointing out the mistake. I checked for r but forgot to check for h.
  16. // It's now fixed to check both.
  17.          printf("Enter radius and height of cone(999 to end): ");
  18.          scanf("%f%f", &r, &h);
  19.          
  20.          if (r !=999){
  21.           volume = (((1.0/3.0) * M_PI) * (r*r)*h);
  22.           printf("radius\theight\tvolume\n%.2f\t%.2f\t%.2f\n", r,h, volume );
  23.           total = total + volume ;
  24.                 }
  25.         else{
  26.        
  27.          
  28.           if(total != 0.00){
  29.           printf("The total volume is %.2f", total);
  30.             }
  31.           else
  32.           printf("No reading is entered.");
  33. }}
  34.     getchar();
  35.     return 0;
  36. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement