Hello Kim,
Unless you put braces enclosing all the lines you want to repeat in the ' for 
loop ' it will consider only the line immediately following it (to be repeated 
).i.e,
say ,
for (int i = 0; i < 10; i++)                           for (int i = 0; i < 10; 
i++)
                                                            {
cout<<"Hello"                                                cout <<"Hello "; 
cout <<"World";                                             cout <<"World "; 
                                                            }
Hello ->10 times                                    Hello ->10 times
World ->once only                                  World -> 10 times

Getting my point ??
Again don't mind but you need to develop the concept yourself.Putting queries 
wont be of much help, I suppose - develop your own reasoning. Try a little bit 
of hit and trial as well - it'll help you retain things for long. Anyways we 
are here to help you.
Regards,
Debasish
len_kim <[EMAIL PROTECTED]> wrote:                                  Hi all, 
 
 I'm still new to all this... I am having a bit of difficulty 
 understanding something 
 about nested for loops. In the below program I have 2 cout statements 
 in the inside for loop. The cout <<"Hello "; runs 20 times, as 
 expected, but why does the cout<<"World "; only run 5 times when it 
 appears that it is also part of the inside loop. It seems that the 
 cout<<"World "; is obeying the laws of the outside for loop, not the 
 inside for loop. I tried adding a 3rd and 4th cout statement in the 
 inside loop, and they also ran 5 times, so would appear to be part of 
 the outside loop as well...  Can someone shed some light as to why 
 this 
 is? I hope my question is clear. 
 
 #include <iostream>
 using namespace std;
 int main()
 {
 for (int counter = 0; counter < 5; counter++)
 
 { for (int inside = 0; inside < 10; inside++)
  cout <<"Hello ";
  cout <<"World: ";
 
 }
 
 }
 
 
     
                       


Karmennevaya Dhikaraste, Maaphaaleshu Kadaachanah
                                
---------------------------------
 Here’s a new way to find what you're looking for - Yahoo! Answers 

[Non-text portions of this message have been removed]

Reply via email to