Y
yanyo
hi, im starting out in C prog and im stuck in this code, its supposed to
calculate this inputs and give out the total expense of gas...
#include <stdio.h>
int main() {
int miles_per_gallon, gastank, miles_per_month;
float total_cost, gas_price;
total_cost= gastank*gas_price/miles_per_gallon*miles_per_month/12;
printf("How many miles per gallon does your car get?\n");
scanf("%d", &miles_per_gallon);
printf("What is the size of your gas tank in gallons?\n");
scanf("%f", &gastank);
printf("What is the price of gasoline per gallon?\n");
scanf("%d", &gas_price);
printf("How many miles do you drive in a month?\n");
scanf("%d", &miles_per_month);
printf("The cost of gas for the month is %1.2f\n",total_cost);
return 0;
}
for some reason i only get zero when i run it i tried changing parethesis
but that didnt work either..
calculate this inputs and give out the total expense of gas...
#include <stdio.h>
int main() {
int miles_per_gallon, gastank, miles_per_month;
float total_cost, gas_price;
total_cost= gastank*gas_price/miles_per_gallon*miles_per_month/12;
printf("How many miles per gallon does your car get?\n");
scanf("%d", &miles_per_gallon);
printf("What is the size of your gas tank in gallons?\n");
scanf("%f", &gastank);
printf("What is the price of gasoline per gallon?\n");
scanf("%d", &gas_price);
printf("How many miles do you drive in a month?\n");
scanf("%d", &miles_per_month);
printf("The cost of gas for the month is %1.2f\n",total_cost);
return 0;
}
for some reason i only get zero when i run it i tried changing parethesis
but that didnt work either..