New to programming and learning c++

I have absolutely no experience in programming but im currently taking a c++ course at my university for my biotech degree. If i like it enough i might consider on taking my major's bioinformatics track. Problem is, i understand the syntax in c++ but i just dont get the logic..especially on the loops. So i was wondering...should i maybe learn an easier language along with c++ to try to understand the logic? maybe ruby or python?
Last edited on
What aspects of loops are you having difficulty understanding?

And learning a separate language I imagine would be more of a distraction from C++ and less of an assistance. You would just have to unlearn all your ruby/python habits when approaching c++ again. But then again, I'm no multilingual genius myself, and my inexperience limits my credibility.
try to do small programs which using loops.
This is only way to clear your doubts and build your confidence in loops and other cpp concepts.
Well NullInfinity u may have a point...thing is i just dont get the logic of nested loops...is there a way that i can predict the output by writing it on paper or something
Apologies for the late reply.

For me, keeping a track of nested blocks of code has always been a matter of format.

That is, I find it always helps to keep my scope delimiters (curly braces) vertically aligned.

Some people do it like this
1
2
3
4
5
6
while (condition){
	//loop content
	while (anotherCondition){
	//another loop
	}
}



Once you have nested loops though, neglecting to put your opening scope delimiter one line after the while statement (or whatever you're doing) can make things hairy. So I always do it like this

1
2
3
4
5
6
7
8
while (condition)
{
	//loop content
	while (anotherCondition)
	{
	//another loop
	}
}



It becomes, for me at least, much easier to see where something begins and ends by vertically aligning the symbols. It makes the file a bit longer, in terms of line count, but I'm not sure if it affects anything else like the program's performance and time needed to compile.

Most modern IDEs, by the way, have a feature where if you highlight a curly brace by hovering over it with your mouse or by selecting it, the IDE will highlight its corresponding scope delimiter, wherever it is, elsewhere in the program. Try it!

---

Other matters:

Once a program becomes large enough, no single human brain is capable of grasping it all at once. Instead, you delegate tasks in an organized manner (using design patterns and algorithms, about which there are many books written) in such a way that you only have to think about individual specialized parts of the program.

This is why we have development teams, and large single-human projects are considered painstaking and ambitious.


There are also UML diagrams:

http://www.youtube.com/watch?v=OkC7HKtiZC0&list=PLGLfVvz_LVvQ5G-LdJ8RLqe-ndo7QITYc

UML stands for "Unified Modeling Language." It's a diagram notation system used to model complex programs across many languages.

I'm learning about them right now, and while they're overwhelming, they're often essential to professional work done by large teams. Learning about them now will save you a lot of headaches later.
Last edited on
Topic archived. No new replies allowed.