I keep getting errors in my code. I can enter the first number 1 fine but then is says that letter c or a is not initialized. What am I doing wrong? This is what i have so far

// Exercise 8.13: ComparingRates.cpp
// Application that calculates the amount of money the user will have
// after 10 years at several interest rates.


#include <string>
#include <iostream>
#include <iomanip>
using namespace std;

void main ( )
{
int choice;
double a, b, c;
char an;
cout << "Please enter the operation you want" << endl;
cout << "Press 1 for addition" << endl << "Press 2 for subtraction" <<
endl << "Press 3 for division" << endl << "Press 4 for multiplication"
<< endl;
cin >> choice;
cout << "Please enter the numbers you want to do calculation with" << endl;
while (an = 'y')
{
if (choice == 1)
{
c = a + b ;
}
if (choice == 2)
{
c = a - b;
}
if (choice == 3)
{
c = a / b;
}
if (choice == 4)
{
c = a * b;
}
cout << "Here is your result: " << c << endl;
cout << "want to do it again?" << endl;
cin >> an;
}
} 

 /**************************************************************************
  * (C) Copyright 1992-2005 by Deitel & Associates, Inc. and               *
  * Pearson Education, Inc. All Rights Reserved.                           *
  * DISCLAIMER: The authors and publisher of this book have used their     *
  * best efforts in preparing the book. These efforts include the          *
  * development, research, and testing of the theories and programs        *
  * to determine their effectiveness. The authors and publisher make       *
  * no warranty of any kind, expressed or implied, with regard to these    *
  * programs or to the documentation contained in these books. The authors *
  * and publisher shall not be liable in any event for incidental or       *
  * consequential damages in connection with, or arising out of, the       *
  * furnishing, performance, or use of these programs.                     *
  **************************************************************************/

Tell me if you see a problem here :

char an;
cout << "Please enter the operation you want" << endl;
cout << "Press 1 for addition" << endl << "Press 2 for subtraction" <<
endl << "Press 3 for division" << endl << "Press 4 for multiplication"
<< endl;
cin >> choice;
cout << "Please enter the numbers you want to do calculation with" << endl;
while (an = 'y')

Then you say :

cout << "Please enter the numbers you want to do calculation with" << endl;

In which you don't do this :

cin >> a >> b;
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.