All pastes #800000 Raw Edit

Dark3Lite

public text v1 · immutable
#800000 ·published 2007-11-28 00:56 UTC
rendered paste body
A fixed percentage of water is taken from a well each day. Request values for W and P where

W  is the amount of water in the well taken out each day

P is the percentage of water in the well take out each day

Write a program to print the number of the day, the amount of water taken out for that day and the amount reaming at the end of each day. The output should be terminated when 30 days have been printed or the amount remaining is less than 100 liters.

This is what I have thus far...! but not getting it do finish..

*/

#include <stdio.h>

main ()

{
     
     int amtTaken, amtRemaining, day, per_water, water;
     
     day = 1; 
       
     printf("Enter amount of water in well(litres): ");
     scanf("%d", &water);
     
     printf("\nEnter %% of water taken: ");
     scanf("%d", &per_water);
     
     amtTaken = (water*per_water)/100;
     
     amtRemaining = water - amtTaken;
     
     printf("\nDay  Amount      Amout\n");
     printf("     Taken       Remaining\n\n");
     printf("%d  %5d   %9d\n", day, amtTaken, amtRemaining);
     
     do{
                          
     amtTaken = (amtRemaining*per_water)/100;
     
     amtRemaining = amtRemaining - amtTaken;
     
     day++;
          
     } while ( (day < 30) || (water < 100));
     
     
     printf("%d  %5d   %9d\n", day, amtTaken, amtRemaining);
     
     
     
     
}