Sunday, October 17, 2010

[DSA] Common Mistakes in Programming

There are few categories of mistakes/error/bug in programming. Suchs as logic erros, syntax errors, core dumpz (run time error)/
I came across many many types of mistakes in programming that student commit. These mitakes fall majorly into the syntax error which is the easiest to troubleshoot. As compared to logic errors, there are formal mathematical way to prove that the logic and the premise it holds.

As the old programming guru’s mantra: “It takes more pairs of eyes to spot the bug”

Below is NAF (Need A Fix) buggy code that I have created (50lines only....easy). Your "TASK" is to "SOLVE IT", "FIX IT", PLS DO NOT EAT IT!!!

PLS POST/SHARE your answers here, add in as comments.
//=======================================================




//=========================================================

NO KICK???????????!!!!!!!!!!!

try the below (100lines, 5qns), covers strings, STL containers, iterators. Errors such as syntax error, runtime error and a little bit of logic error.

Note: "HEROES ONLY"

//==========================================================



19 comments:

  1. Cannot go pass the void errors. Any tips?

    ReplyDelete
  2. for the 50-line. 1st void error already cannot pass.

    ReplyDelete
  3. erm... the error is at which line?

    ReplyDelete
  4. He's talking about line 6: "void whyCallMe(input){". "input"'s variable type is not declared.

    ReplyDelete
  5. cher, I am stuck for the common mistakes program...


    int result = 0;
    string strIn = "";
    cout << "Spot the common mistake(s)" << endl;

    result = func1(int 10,int 20);
    cout << "sum 10+20: " << result << endl;


    this part there is a syntax error and I cannot find it... can help me?

    ReplyDelete
  6. @ heng gnee: When you call a function, you don't declare the values that you pass to the function.

    ReplyDelete
  7. @heng gnee,
    ==>result = func1(int 10,int 20);

    i already mentioned this example in class. just pass the number directly will do.

    ReplyDelete
  8. http://snipt.net/hengnee/50-error-code

    this is what I have managed so far...

    ReplyDelete
  9. Johnathan Teo DCPE 2A/05November 5, 2010 at 3:31 PM

    http://snipt.net/sgxbuster/50-line-not-com


    not done dunno how do le

    ReplyDelete
  10. @Johnathan Teo
    Use your codeblock compiler to check the errors. You need to be able to recognize what kind of error it is when they show you. You need to know this during the lab tests, quizzes and exams.

    ReplyDelete
  11. @Johnathan, take a look at syntax error. usually they have a red wormly line below it. like you have a typo in m$ word.

    then look at compiler output in the command window. it will give you some hints on the error.

    ReplyDelete
  12. http://snipt.net/hengnee/success-in-removing-mistakes


    the getline part was the only part that I didn't get in the previous version of my post.

    had to do damn lot of research to know that getline(cin, whatever) to input string and pass it through function... sorry for the very late work...

    ReplyDelete
  13. @heng gnee,
    is better late then never.
    anyway, the hints already released on the week discuss about I/O stuff

    ReplyDelete
  14. @heng gnee,
    is better late then never.
    anyway, the hints already released on the week discuss about I/O stuff

    ReplyDelete
  15. http://snipt.net/jellybanana/naf-50-lines

    with a little help from henggnee, i have managed to finish this. Sorry bout the delay, I just started my engine haha.

    ReplyDelete
  16. http://snipt.net/jellybanana/naf-100-lines

    Help me check if I've done it correctly, thank you.

    ReplyDelete
  17. @yiwei,
    being later is better then never

    ReplyDelete