Hi i'm new to C programming, and i have this homework which i need to do on compounding interest, i would like to know whats wrong.
it says, "Run-Time Check Failure #3 - The variable 'HoursWorked' is being used without being initialized." same with other variables.
below is my code. Please help me! Help appreciated :D
oh, and im using microsoft visual studio 2005, school default, cant upgrade. settings used its general settings.

#include <stdio.h>
#include <math.h>
#define FALSE 0
#define TRUE 1


void main (void)
  { 
	int HoursWorked,Hours,Hour,userc,Y,Years,menu,million,done,millionare,settings_complete; 
	float MoneySpent,MoneyMade,MoneyLeftOver,MoneyLeft,MoneySpentI,PricePerHour,startbalance,Total,WeekMoneyMade,CI;


  while(done = true) //While Loops 

  { 
	printf("This program calculates the compounded interest in each year.\n");
	printf("\n Menu \n"); 
	printf("1 - Settings\n"); 
	printf("2 - Account Summary\n");
	printf("3 - Quit\n"); 
	printf("******************\n");
	printf("Enter Your Choice:");
	scanf("%d",&menu);
  switch(menu) 
  { 

  case 1:

	printf("\t Menu - Settings\n"); 
	printf("1 - Edit - Money Per Hour\n"); 
	printf("2 - Edit - Hours Worked\n"); 
	printf("3 - Edit - Expenditures\n"); 
	printf("4 - Edit - Current Interest\n"); 
	printf("5 - Edit - Savings Menu\n"); 
	printf("6 - Quit\n"); 
  scanf("%d",&menu);
  switch(menu) //Another switch structure 

  { 

  case 1: 

	printf("How much do you make an hour: "); 
	scanf("%d",&PricePerHour);
	done=false; 
	break; 

  case 2: 

	printf("How many hours do you work a week? (1-168): "); 
	scanf("%d",&HoursWorked);
  if ((HoursWorked <= 0) || (HoursWorked >= 168)) 
  { 
	printf("Your Number was Invalid. Please enter a Number between (1-168):"); 
	scanf("%d",&HoursWorked);
  } 
  done=false; 
  break; 
  
  case 3: 
	printf("How much money do you plan on spending Weekly? "); 
	scanf("%d",&MoneySpent);
  if (0 > MoneySpent) 
  { 
	printf("Your Number was Invalid. A Positive Number Please: "); 
	scanf("%d",&MoneySpent);
  } 
  done=false; 
  break; 

  case 4: 
	printf("What is the Current Interest Rate? "); 
	scanf("%d",&CI);
  if (0 > CI) 
  { 
	printf("Your Number was Invalid. A Positive Number Please: "); 
	scanf("%d",&CI);
  } 
  done=false; 
  break; 

  case 5: 
{ 
	printf("\\t Menu - Savings\n"); 
	printf("1 - Years\n"); 
	printf("2 - Edit Account Balance\n"); 
	printf("3 - Millionare"); 
	printf("4 - Quit"); 
	scanf("%d",&menu);
	switch(menu) 
  { 
  case 1: 
	printf("How Many Years would you like to have the total savings calculated for\n"); 
	printf("(Any Number Greater then 1, 0 if You dont Wish To use this option):"); 
	scanf("%d",userc);
	done=false; 
	break; 

  case 2: 
	printf("What is the Current Balance of Your Account? \\n"); 
	printf("(Any Number Greater then 1, 0 if You dont Wish To use this option): \\n"); 
	scanf("%f",&startbalance);
	done=false; 
	break; 

  case 3: 

	printf("Type 1, if you would like to calculate the time needed to become a millionare."); 
	printf("0 for No."); 
	scanf("%d",&million);

  if (million=1) 
{millionare=true;} 
  else 
  {millionare=false;} 
  done = false; 

  case 4: 

  done=true; 
  break; 

  default: 
  printf("You Have Enter an Invalid Choice. "); 
  done=false; 
  break; 
  done=false; 
  break; 
}
  case 6: 

  done=true; 
  break; 

  default: 
  printf("You Have Enter an Invalid Choice. "); 
  done=false; 
  break; 
  } 
  
 while (done=true); 
 {
  settings_complete = true; 
  done=false;
  break;
 }

}
  
  case 2:
	if(settings_complete = true) 
{ 
 { 
  if (millionare=true) 
 { 
  {
  int short Y,Z;
  float X,Xvariable,Yvariable;

  // Calculates Total Hours Worked During the Year 
  Hours = HoursWorked * 56; 
  Hour = HoursWorked; 

  // This then Calculate How Much Money Was made (Weekly & Yearly) 
  MoneyMade = PricePerHour * Hours; 
  WeekMoneyMade = PricePerHour * Hour; 

  // Simply calculation the money spent to a yearly value 
  MoneySpentI = MoneySpent * 56; 

  // Calculates the Net Profit (Weekly & Yearly) 
  MoneyLeftOver = MoneyMade - MoneySpentI; 
  MoneyLeft= WeekMoneyMade -MoneySpent; 

  // Initializes Required Variables For the Following Calculations
  X = MoneyLeftOver; 
  Z = 0; //Control Variable for the second statement 
  Y = 0; //Control Variable for the first statement 
  Years = 0; //You dont make money before you begin the year, but after the loop goes around once 

  //The value is increased to 1 
  Yvariable = MoneyLeftOver; //Transfers the value to another variable to prevent a change to the main variable 
  Xvariable = startbalance; //See Above 

  // Annual Interest (Salary) 
  do //A do/while loop 
  { 
  Yvariable = ((Y * MoneyLeftOver) * CI) + X; 
  Y++; 
  Years++; 
  } 
  while (userc = Y + 1); 
  // Annual Interest (Initial Bank Balance) 
  do 
  { 
  Xvariable = ((Z * startbalance) * CI); 
  Z++; 
  } 
  while (userc = Z + 1);  
  // Account Balance plus the sum of the salary balance; 
  Total = Yvariable + Xvariable; 
  } ; 
} 

  else 
  { 
	int short Y,Z; 
	float X,Xvariable,Yvariable;
  // Calculates Total Hours Worked During the Year 
  Hours = HoursWorked * 56; 
  Hour = HoursWorked; 

  // This then Calculate How Much Money Was made (Weekly & Yearly) 
  MoneyMade = PricePerHour * Hours; 
  WeekMoneyMade = PricePerHour * Hour; 

  // Simply calculation the money spent to a yearly value 
  MoneySpentI = MoneySpent * 56; 

  // Calculates the Net Profit (Weekly & Yearly) 
  MoneyLeftOver = MoneyMade - MoneySpentI; 
  MoneyLeft= WeekMoneyMade -MoneySpent; 

  // Initializes Required Variables For the Following Calculations 
  X = MoneyLeftOver; 
  Z = 0; 
  Y = 0; //This is set to zero because you dont have a salary before the year begins 

  //But because of the loop the value after one loop is increased by 1(Y++) 
  Years = 0; 
  Yvariable = MoneyLeftOver; 
  Xvariable = startbalance; 

  // Annual Interest (Salary) 
  do 
{ 
Yvariable = ((Y * MoneyLeftOver) * CI) + X; 
Y++;
Years++; 
} 

  while (userc = Y + 1); 
  // Annual Interest (Initial Bank Balance) 
do 
  { 
  Xvariable = ((Z * startbalance) * CI); 
  Z++; 
  } 

  while (userc = Z + 1); 
  // Account Balance plus the sum of the salary balance; 
  Total = Yvariable + Xvariable; 
  } 
  } 
} 

  else
  { 
printf("Please Edit The Settings Before Choosing this options.\n"); 
  } 
done=false;
break; 

case 3:
done =true;
break; 

  default:
  printf("You Have Enter an Invalid Choice.\n");
  done=false; 

} 
}
}

i test your program, here is some suggestions:
1) use int main() instead of void main()
2) the first menu of the switch should do the menu 1 first and then menu 2 so if at first i choose menu 2 at the first time it will cause problem.
3) why you use

done=false; break;

every time after the switch case?? its that mean it will break down the project and cause problem.
4) if you know c++ use c++ instead of c , cause scanf() is not safe

i am using vs 2008 Express Edition which is good for the beginners
ps: if i am wrong about the above opinions correct me.
thx

That means you forgot to initialize your values when you declared them. (Usually this just throws a warning, but each compiler can be different). Just give every variable you declare a starting value, by putting it in brackets (), ie:

int iHoursWorked(0), iTime(0), etc...

Basically i don't have problem in the compiler but have problem when run it.

there are many horrible errors here:

The first that will take you a while to see (and most modern compilers would have flagged as a serious warning) is that you have while(done=true) I am sure that you wanted while(done==true) since the first while loop is ALWAYS true. Interestingly you define
TRUE to be 1 but then use true and false in your code. You are lucky that you get true/false from math.h.

What else: I work 39.5 hours a week :) But you use a lot of integers for things that can have fractional value.

How are there 56 weeks in a year?

Finally, the answer needs a bit of modification, Interest is paid daily and you can calculate the compound interest using a geometric series. e.g

[tex]
T = P(1+(R/365))^{n}
[/tex]

R is the fractional rate e.g. 5% is 0.05. n is the number of days, P is the principle and T is the total after n days. Note that banks normally use 365.25 as the divisor even if you savings didn't occupy a leap year.

well, i think its cause im using microsoft studio visual 2005?
i made this code based on cout and cin. assuming printf and scanf was basically the same thing.
i cant use any other software, cause the program is marked based on 2005.
yes the whole code is a mess and i assume its not even finishsed. there's just something wrong, and im stuck, i dont know where i should start. or should i just restart everything?

i have to make the program based on printf and scanf, using switch-case, while and for loops, if-else.
any idea?

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.