#include <stdio.h>

#define CALORIES 150
#define  WEIGHT 15

int main()
{
    double beer;
    double money_spent;
    double total_spent;
    double total_beer_consumed;
    double total_calories_consumed;
    double weight_gain;
    
    printf("On average, how many beers will you consume each day?\n");
    scanf("%lf\n", &beer);
    
    printf("On average, how much will you pay for each can of beer?\n");
    scanf("%lf\n", &money_spent);
    
    // CALCULATIONS
    
    total_beer_consumed = beer *365; // total beer consumed the whole year
    printf("That is approximately %.2lf beers in one year.\n", &total_beer_consumed);
    
    total_calories_consumed = beer * CALORIES; // total calories consumed
    printf("In one year, you will consume approximately  %.2lf calories from beer alone.\n", &total_calories_consumed);
    
    weight_gain = beer * WEIGHT; // total weight gained throughout the whole year
    printf("Without diet or exercise to counter these calories, you can expect");
    printf("to gain %.2lf pounds from drinking that much beer this year.\n", &weight_gain);
    
    total_spent = (beer * money_spent)*365; // money spent on beer this year
    printf("You will spend approximately %.2lf on beer this year.\n", &money_spent);
    
    system("pause");
    return 0;
}

this is what i want the program to do,
On average, how many beers will you consume each day?
2.5
On average, how much will you pay for each can of beer?
1.25
That is approximately 912.50 beers in one year.
In one year, you will consume approximately 136875.00 calories from beer alone.
Without diet or exercise to counter these calories, you can expect to gain 37.50 pounds from drinking that much beer this year.
You will spend approximately $1140.62 on beer this year.

BUT when it asks on the 1st questions it asks me to put in two values before asking the second question

and the calculations dont work

Recommended Answers

All 4 Replies

Take the '\n' out of your scanf format specifiers.

still when i compile and run the code, no calculations are performed

You're printing the addresses of variables rather than the values. scanf and printf are not the same.

i have already sorted it thank you

i figured it was because of i put & in front of the variables in the print statements of the

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.