Hi!
I need to convert the following while loop:
count = 1;
while (caloriesForIte m != 0, count != numberOfItems )
{
cout<<"Enter the calories: ";
cin >> caloriesForItem ;
totalCalories += caloriesForItem ;
count++;
}
This is what I have come up with:
totalCalories += caloriesForItem ;
for (count = 1; caloriesForItem != 0; count != numberOfItems)
{
cout<<"Enter the calories: ";
cin >> caloriesForItem ;
count++;
cout << "Total calories eaten today = " << totalCalories << endl;
}
However the output is not the same?
any pointers perhaps?
I need to convert the following while loop:
count = 1;
while (caloriesForIte m != 0, count != numberOfItems )
{
cout<<"Enter the calories: ";
cin >> caloriesForItem ;
totalCalories += caloriesForItem ;
count++;
}
This is what I have come up with:
totalCalories += caloriesForItem ;
for (count = 1; caloriesForItem != 0; count != numberOfItems)
{
cout<<"Enter the calories: ";
cin >> caloriesForItem ;
count++;
cout << "Total calories eaten today = " << totalCalories << endl;
}
However the output is not the same?
any pointers perhaps?
Comment