38
cipher
8y

!rant
First time working with 2-D arrays. Think I did good :).

Comments
  • 6
    Yeah man but that system("pause"); is killing me
  • 1
    @cosinusdealfa unless this quizzes and students program gets released i see no problem with it. :)
  • 5
    It's the defines (which ignore scope) inside a function that bothers me
  • 0
    Shouldn't the counting var be initialized IN the for-loop? At least that's how I learnt it
  • 3
    @Paralax it is initialized as part of the 'for' statement e.g. i = 0. If you initialized it inside the 'for' it would loop forever as the counter would keep being effectively reset during each new loop.
  • 2
    @Paralax really depends, I know some versions of C don't support the for (int i = 0;;) {} syntax.
  • 1
    When you place a comment move it to a method with a descriptive name.
  • 0
    @cosinusdealfa
    I need it to see the output in cmd, or at least that's what my professor taught us.
  • 0
    @DrEmann
    I'm not sure what you mean.
    My professor hasn't mentioned scopes just yet with constants. I'll make sure to look into it!
  • 1
    Just a heads up this code will throw an error if students or quizzes is equal to zero. Not sure if you need to handle that case, but just letting you know :-).
  • 1
    @Yankeesrule
    Oh yeah I'm aware, thanks though:).

    I could have went through and handled all cases but that wasn't required for my spec (this is just an assignment) and I had other things to do, normally I would have.

    I should mention everyone I'm in a Intro to programming class (COP 1000) so there's no pushing to production or anything like that. 😅
  • 1
    @QuantumAtom yeah I figured it was for class but wasn't sure if it was a case you missed. Looks good other than that. Good job!

    As a senior software engineer I'm pretty sure I spend way more time thinking about the crazy border cases that could potentially break my code than the happy cases.
  • 0
    @Yankeesrule
    Thank you!
    But lol, if I ever do code for something more than an assignment (I'm sure I will; also at times I'll focus on bad cases depending on the assignment and my time) I'm sure I'll focus more on the bad ones as well. In your eyes do you think that's better than doing the opposite, focusing on the good cases way more than the bad ones?
    I personally would think so.
  • 1
    @QuantumAtom it depends on the complication to code the border cases. If it's easy, I knock it out right away. If it will be very complicated and make the code difficult to read, etc. then I will raise it up with the clients. They may say the case will never occur and so don't worry about it. And if so, case closed.

    If not, I make it a separate story (basically a requirement) so I can focus on that at a separate time. At that time I will try to see if I can move whatever validations and checks are needed for it into a separate method/function so it doesn't interfere with the main business logic making things hard to read. I can then document the case and reasoning behind it at the top of the function as well without it being in the way.

    But yes, it is important to think about border cases early so you can at least tell the users. And always in email so you have written proof that the issue is okay for when they change their mind :-).
  • 1
    @Yankeesrule
    Oooh yes that's very true. It can make the code complicated and hard to read.
    And yeah that makes sense to ask the client and get their opinion. As if they don't think they'll come across that case and tell you not to worry, that's saving you time that you can put towards other things.
    And ooh yeah I'd imagine having documentation and the proof would be very important.
  • 1
    @XirusDaVirus Sorry, I meant in the for-brackets e.g. for (int i=0...){}, not at the top of the function
  • 1
    @Paralax
    I've never tried it like that, will next time. Thank you.
Add Comment