One metric ton is approximately 2205 pounds. Write a program that prompts the user to input the amount of rice, in pounds, in a bag. The program outputs the number of bags needed to store one metric ton of rice.
#include <stdio.h>
#define POUNTS_PER_TON 2205
int main() {
int pounds_in_bag;
int bag_number;
printf("Enter aa amount of pounds in one rice bag: ");
scanf("%d", & pounds_in_bag);
bag_number = POUNTS_PER_TON / pounds_in_bag
+ (POUNTS_PER_TON % pounds_in_bag ? 1 : 0);
printf("You need %d bags to pack one ton of rice\n");
return 0;
}
Comments
Leave a comment