+ 1
What is the best practice for learning c++ loops?
hello every body, i m in 12 grade and currently, we r studying loops, but it seems something ghost languageđđ. i want to know what is the best practice for learning loops... thanks in advanceđđ
2 Answers
+ 7
The best way to learn loops in my opinion is what we call as "Dry Run"
Now what this "Dry Run" really is?
Well, it is simply manual compilation.
It means you have to analyse how looping really works step by step.
Now let us consider a simple example
int i;
for(i=0;i<10;i++)
cout<<i;
Step 1: variable i is intialized as 0
Step 2: then it checks i<10 which is true since 0 is < 10
Step 3: prints the value of i
Step 4: increments value by one (i++)
Now this process continues untill the condition becomes false.
i.e. i becomes 10 ( 10<10 is false) and the loop ends after this.
Hope this helped u!
+ 2
it helped me