Loops C++

Should i really need to master loops (while,for,do while) in C++ ?
I get it but when im trying some beginner exercises i cannot do it.
all i can do is looping numbers and its square.
Should i really need to master loops

Yes.

Standard library does provide several algorithms that do loops on your behalf, but they do not apply to every situation. Furthermore, understanding the concept of iterative algorithm (aka loops) is extremely useful.
trust me you want to master them...thumb rule for loops:

While loop - use when number of executions(iteration) is unknown

for loop - use when number of executions is known, mostly use with arrays

do while - use when you want to execute some code once regardless
of your condition being true or false

you will use them with almost everything because 90% problems are logic based and there is no other way of doing them without loops and condition statements(if/else).
Last edited on
Loops are one of the most fundamental concepts of programming. So yes, you need to master it.

What are you having problems with in particular? Would be more than happy to help.
I get it but i really do not know my problem in loops. like what i said all i can do is looping numbers :( Can someone give me exercises hehe
Show the loop that you can do.
Last edited on
@keskiverto only this
1
2
3
4
for(int i=0; i<100; i++)
{
cout<<i <<" == " << i*i<<endl;
}
and the while loop of it
and
1
2
for(char letter='a'; letter<'a'+26;letter++)
cout<<letter;;


abstractionanon thanks for the link
Topic archived. No new replies allowed.