I am writing a simple program in C, but I cannot figure out why my if statement is not working. when I compile and run, it ignores the third scanf and whatever the user inputs, it skips the statement and just uses the initial value for the variables. Here is the code that I have. Someone please help me it is very annoying.
Code:
/* Program to calculate weight gained and money spent from beer consumption */
//Program By: James T Garner - 2006
#include <stdio.h>
int main(void)
{
//declare variables
double b, c, cal=150, year=365, leap;
int yes=1, no=2;
//User Input
printf("\nOn average, How many beers (12 oz) do you drink a day?\n");
scanf("\n%lf", &b);
printf("\nOn average, How much money (US dollars) do you spend on each beer?\n");
scanf("\n%lf", &c);
printf("\nIs it Leap Year? (1 = yes, 2 = no)\n\n");
scanf("%lf"), &leap;
//If statement
if (leap == 1)
cal = 150.4, year = 366;
//Result Output
printf("\nYou will drink about %.2f beers this year.\n", b*year);
printf("\nYou will spend about $%.2f this year on beer itself.\n", (b*year)*c);
printf("\n\nUnfortunately, you will gain %.2f calories from beer,\n", (b*year)*cal);
printf("\nWhich is equal to a gain of %.2f pounds from drinking beer.\n\n", (cal*b*year)/3500);
//Disclaimer
printf("\n\n");
printf("\nCalculations are based on information from www.realbeer.com\n\n");
//System pause to pause the program window for viewing
system("pause");
return 0;
}