1. Repitition Structure

I am having a problem to do the coding for the following:
A repetition structure that will prompt the user for a value, read that value into the variable price, increment the variable total by the value entered, and continue repeating the process until total is greater than 10.00 or until the user enters 0 as a value to indicate that they are finished entering values.

Would anyone be willing to help me out a little. This is what I come up with so far:

#include <iostream.h>
int main()
{
for(int x=0;x<10;x++)
{
cout<<x<<endl;
}

return 0;
}

2. hmm.. whos this gues here.. posted a code from some old file to get things done.. keep it up..

this is how i would do it
Code:
```# include <iostream.h>

int main()
{

double num=-1;
double total=0;

while(num!=0 && total<10)
{
cout<<"\nEnter a number > ";
cin>>num;

total=total+num;

}

return 0;
}```

3. Work off this:
Code:
```#include <iostream>

using namespace std;

int main()
{
double userEntry = 1;
double totalEntry = 0;

while(totalEntry < 10.0 || userEntry != 0)
{
cout << "Please enter a number: ";
cin >> userEntry;
totalEntry += userEntry;
}
cout << endl << "Your total entry was: " << totalEntry << "." << endl;
return 0;
}```
--edit--
Dough! Foiled by vasanth, atleast when I used code tags, I indented, lol.

4. Originally posted by stumon
Work off this:
Code:
```#include <iostream>

using namespace std;

int main()
{
double userEntry = 1;
double totalEntry = 0;

while(totalEntry < 10.0 || userEntry != 0)
{
cout << "Please enter a number: ";
cin >> userEntry;
totalEntry += userEntry;
}
cout << endl << "Your total entry was: " << totalEntry << "." << endl;
return 0;
}```

Your program is completely wrong.. Looks like you are confused with the || (or) stuff in the while loop.. your program would run into an infinite loop... the or has to be substituted by and &&.. though in normal english it may sound logical.. in programming it has a different meaning.. the first condition is always checked and if it is true the next condition is never checked...

5. >>the first condition is always checked and if it is true the next condition is never checked...

a.k.a. "short circuit logic"
I would have figured that out if i ran the program. lol. It was something for him to work off of.

6. Your program is completely wrong.. Looks like you are confused with the || (or) stuff in the while loop.. your program would run into an infinite loop... the or has to be substituted by and &&.. though in normal english it may sound logical.. in programming it has a different meaning.. the first condition is always checked and if it is true the next condition is never checked...
A good way to think of it (or at least the way I think of it), is that when you do A && B ("A and B"), the loop or if statement only executes if A and B are both true. With A || B ("A or B"), the loop/if only executes if either A or B is true (or if both are true!).

7. Ok then, lets just get the confusing and/or situation out the way, use a for() loop, just like he started with.
Code:
```#include <iostream>

using namespace std;

int main()
{
double userEntry = 1;
double totalEntry = 0;
int i = 1;

for (i = 0; totalEntry < 10.0; i++)
{
cout << "Please enter a number: ";
cin >> userEntry;
totalEntry += userEntry;
if (userEntry == 0.0)
break;
}
cout << endl << "Your total entry was: " << totalEntry << "." << endl;
return 0;
}```

8. Originally posted by codegirl
A good way to think of it (or at least the way I think of it), is that when you do A && B ("A and B"), the loop or if statement only executes if A and B are both true. With A || B ("A or B"), the loop/if only executes if either A or B is true (or if both are true!).
well thats right.. but the problem usually arrises when you use negating conditions like

a!=7 || b!=3

something like that.... Here it is a bit more problematic for a newbie to understand...

9. Thanks to all for your help!

Thanks for your help. I am very new to C++ and is working hard to understand.

Thanks a lot.

JJ1