Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

finding this hard/annoyingly brain demanding...logically

Assist_arkAssist_ark Posts: 1Member
Hey guys,
First ever post here. and must say, I hope to learn and be of help to others on this forum.

As the topic suggest, I'm kinda finding the code below rather annoyingly confusing logically (Accelerated C++ (annoying examples or whaat)). The logic behind it makes me think way too much. It's from a book and this is the second chapter. This is a snippet of the actual code.

[code]
for (int r = 0; r != rows; ++r) {
//row=5; col=
string::size_type c = 0;

// invariant: we have written `c' characters so far in the current row
while (c != cols) {

// is it time to write the greeting?
if (r == padr + 1 && c == padc + 1) {
cout << greeting;
c += greeting.size();
} else {

// are we on the border?
[b]if (r == 0 || r == rows - 1 ||
c == 0 || c == cols - 1)
cout << "*";[/b]
else
cout << " ";
++c;
}
}

cout << endl;
}[/code]
Question is: Since I'm finding this kinda confusing, does that mean I'm not cut out to be a programmer? Asking because, I understand the code, just don't see the point. Why the author decides to use the method he's using. I'm always finding myself going through the code line by line, to get what its doing. But at the same time, it is easy.

The bolded is the bit that's pissing me off. So many logic-ors maybe. Really don't know.

Comments

  • GorrisGorris Posts: 4Member
    Just because you find the code confusing doesn't mean you aren't meant to be a programmer. I am a computer programming major and I think the way he wrote the code is very confusing.

    The thing about programming is that there are so many different ways to write a program you just have to find you style.

  • GorrisGorris Posts: 4Member
    Just because you find the code confusing doesn't mean you aren't meant to be a programmer. I am a computer programming major and I think the way he wrote the code is very confusing.

    The thing about programming is that there are so many different ways to write a program you just have to find you style.

Sign In or Register to comment.