# simple simple design question

• 05-30-2005
Chaplin27
simple simple design question
I'm going to cut right to the chase and show some code:
Code:

```while(times_value < 11) {         product = 7 * times_value;         cout << "7 x " << times_value << " = " << product << endl;         times_value++; }```
Now I know this is a matter of style, but do you think it's better to get right into the processing as I do here with product being given a value at the start? Or.... do it like this...
Code:

```while(times_value < 11) {         cout << "7 x " << times_value << " = ";         product = 7 * times_value;         cout << product << endl;         times_value++; }```
Where the info is printed and processed in the same way you would think it out? I know this is a stupid question, I'm just curious what other people think about the order of statements.
-Chap
• 05-30-2005
mrafcho001
Code:

```while(times_value < 11) {     cout << "7 x " << times_value << " = " << 7 * times_value << endl;     times_value++; }```
• 05-30-2005
Daved
Or:
Code:

```for(; times_value < 11; ++times_value) {   cout << "7 x " << times_value << " = " << 7 * times_value << endl; }```
• 05-31-2005
ksarkar
while(times_value < 11)
cout << "7 x " << times_value << " = " << 7 * times_value++ << endl;
• 05-31-2005
7stud
Code:

`for(int t=0;t<11;cout<<"7 x "<<t<<" = "<<7*++t<<'\n');`
• 05-31-2005
Daved
BTW, it's fun to come up with shorter and shorter code, but in actual code I'd prefer my version - it is cleanest and clearest, IMO. Between your original two versions, the first is better, keep similar stuff together - first the processing, then the output. If later you decide to skip output if the value is not appropriate, then the second will be harder to update because you do partial output before you compute the value.
• 05-31-2005
xErath
Quote:

Originally Posted by 7stud
Code:

`for(int t=0;t<11;cout<<"7 x "<<t<<" = "<<7*++t<<'\n');`

:p :p nice one... but probably endl would be better... ;)