12. C Program to calculate the gain for milk vendor.
How does this program work?
- In this programme you will learn how to solve a question using c language.
- Here the question is about to calculate gain of a milk vendor when adds 1litere of water for every 4literes of milk.
- This programme perform mathematical calculation and display the result using C language.
Here is the code
#include <stdio.h>
int main(void)
{
int milk_buy,Water_add,buy_cost,sale_cost;
float gain,sum;
printf("How Many Liters Milk vendor Buy: \n");
scanf("%d",&milk_buy);
if(milk_buy>=4)
{
sum= milk_buy/4;
Water_add=milk_buy+sum;
}
buy_cost = milk_buy * 3.25;
sale_cost = Water_add * 4.15;
gain = sale_cost-buy_cost;
printf("\nGain of Milk Vendor %.2f rupees", gain);
return 0;
}