Difficulty understanding for loop iteration results

Pages: 12
Maybe I chose poor words, and I should not have said basic programming principles.

In this example the person was having trouble understanding flow control.
Last edited on
No, your words were fine and you are absolutely entitled to give your opinions.

As somebody who has in the past taught programming - but not in C++, and to engineering, not computer-science, students - the real problem is to reach a happy medium in a class of 100+ between those who just don't get it (regardless of programming language) and those who find it too easy (and consequently get bored and disruptive).

Fortunately, I don't have to teach programming any longer: the syllabus isn't created by those who know anything about it or have to do anything about it. Sadly, there seems to be a move to insist on teaching to the lowest common denominator ... and that bar is very low.

You were right to mention "flow control" - regardless of programming language the basic control statements (if, loops, functions) prove surprisingly difficult to teach, and the old adage that if you are in front of a class of 100 then you will encounter 100 different ways of learning rings very true.

Personally, I find it a little dangerous to get too hooked on one programming language - all have their own particular strengths and weaknesses.
Last edited on
Thank you, but I thought you made a very valid point.

In the world I work, I often have to deal with outside developers. Nowadays mostly sql developers, but in the past it was much more varied.

I find it easier for me to learn to write in a language they're comfortable with, than the other way around.

c++ taught me the basics, and allows me to change languages freely.

Sometimes I have to tell people, I wrote that program 3 years ago, I'll have to relearn the language.

I'm sorry, I'm home today with covid, and I have to much free time. Guess I should read a book.
An engineer, a physicist, and a mathematician were on a train heading north, and had just crossed the border into Scotland. They saw a black sheep in a field.

The engineer looked out of the window and said "Look! Scottish sheep are black!"

The physicist said, "No, no. Some Scottish sheep are black."

The mathematician looked irritated. "There is at least one field, containing at least one sheep, of which at least one side is black."

The statistician : "It's not significant. We only know there's one black sheep"

The computer scientist : "Oh, no! A special case!"
"It may be a better choice. The question is why they're teaching new programmers to use c-style arrays."

That depends on who they are teaching and what the point is. It may be something not well suited for the first C++ class, but at some point, one does need to go over it since C arrays DO appear in a great deal of existing C++ code.

I can't see myself using some sort of object for a local 2 element array used as a lookup table off a bool expression, for example.
I can't see myself using some sort of object for a local 2 element array used as a lookup table off a bool expression, for example.


Yes - but you're an experienced C++ programmer. Knows the strengths and weaknesses and chooses the best tool for the job.

Yes, C++ programmers need to be taught c-style arrays, c-style pointers, c-style strings etc but IMO not at the beginning. First teach them std containers, std algorithms, std string, std managed memory etc etc. Then when they're familiar with these and comfortable using them then introduce the c based stuff as an 'oh by the way there's also this stuff you need to know about'.
Topic archived. No new replies allowed.
Pages: 12