Hi there,
I really can't understand why the do while loop doesn't work for me.
I have this simple program
Code:
//Calculation 1.3: this includes a do...while loop.
#include <iostream>
using std::cout;
using std::cin;
using std::endl;
class Operation
{
public:
void displayMessage()
{
cout <<"Welcome to Calculation 1.3. \nThis program contains a do...while loop.\n";
}
void displayMessage1()
{
int a (0);
int b (0);
int sum;
sum=a+b;
do
{
cout <<"Insert your first number: \n";
cin >> a;
cout <<"Insert your second number: \n";
cin >> b;
cout << "The sum of your number is: "<< sum;
}
while (a>=5 && b<=10);
}
};
int main()
{
Operation calculation;
calculation.displayMessage();
calculation.displayMessage1();
return 0;
}
The actual loop does work but it doesn't calculate the sum, it alway comes up with a sum of 0 and I can't understand why. I have been trying for hours, but I bet it is a silly error.
Any idea at all?
thanks