Homework hint questions.

Would you guys give me hints to what I did wrong? I just finished one of my lessons. Thanks!

http://prntscr.com/bfcdwv

(Can someone define what he means by comments in code)

It wasn't in the book. When I looked at the solution, I didn't understand why his contained comments and mind didn't. I'm not understanding.

His is Ray Warren.

http://prntscr.com/bfcfba

http://prntscr.com/bfcdmu

http://prntscr.com/bfcdgq

I'm not seeing how his solution on this concerning curly brackets is different from mine. Can someone explain what I did wrong?

http://prntscr.com/bfcgad

I understand the rest! Thanks for any help!
closed account (48T7M4Gy)
What he's saying is curly brackets are opened in pairs ie { ... } and they must balance as we all know. So the closing bracket should be labelled with a comment to show which opening bracket it refers to:

1
2
3
4
5
6
7
8
9
10
{ // this opens bracket pair 1


   { // this opens bracket pair 2

    } // this closes bracket pair 2



} // this closes bracket  pair 1 

You won't see a lot of code here doing that but it's not wrong to do it. Just play the game - after all, he's dishing out the marks, Ray's the man.

PS same goes for general comments. Good programming is pretty much self documenting. A good header statement using various conventions avoids clutter with redundant commentary but again just play the game. :)

PPS As a hint use your pseudocode as the comments combined with the header statement. ( That's if you've written some. )
Last edited on
closed account (48bpfSEw)
The Value of a Source Code is calculated by "code metrics". A code has to be readable and understandable for other users therefore comments in your source code is better than not comments or few comments.

http://stackoverflow.com/questions/60394/calculate-code-metrics

Ah, so comments are these things?

//I like pie
// I like cats

He wants me to use comments to clarify what I'm doing?

Thanks so much for telling me about what I was doing wrong with curly brackets!
closed account (48T7M4Gy)
That's the way FBHSIE

BTW the // indicates a comment follows on that line so whatever you type (more or less) is ignored by the compiler.
Last edited on
Why thank you sir.
Topic archived. No new replies allowed.