Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #include <stdio.h>
- #include <math.h>
- //Aminpro
- //https://www.facebook.com/AminproPastebin
- int main(void)
- {
- float r = 0.00;
- float volume = 0.00;
- float total = 0.00;
- float h = 0.00;
- while (r != 999 && h != 999){
- // Thanks Ah Slevin, for pointing out the mistake. I checked for r but forgot to check for h.
- // It's now fixed to check both.
- printf("Enter radius and height of cone(999 to end): ");
- scanf("%f%f", &r, &h);
- if (r !=999){
- volume = (((1.0/3.0) * M_PI) * (r*r)*h);
- printf("radius\theight\tvolume\n%.2f\t%.2f\t%.2f\n", r,h, volume );
- total = total + volume ;
- }
- else{
- if(total != 0.00){
- printf("The total volume is %.2f", total);
- }
- else
- printf("No reading is entered.");
- }}
- getchar();
- return 0;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement