6 Oct 2012

8 Common Programming Mistakes

Here is a List of some common programming mistakes which are mainly faced by the beginners.

1. Undeclared Variables: Before compiling the program or even writing the program we should carefully monitor that the variables we're using are already declared or not. The Compiler didn't understand the variables itself. we have to declare them before compiling.

2. Uninitialized Variables: The Advance languages like JAVA, Python handles the uninitialized variables. However we may get the errors with the Languages like C/C++

3. Setting the Variable to an uninitialized value: Users often start using the variables without initialization which may spread the garbage values to other sections of the program too.

4. Using a Single equal sign to check equality:

int c=10;
if(c=10)
 cout <<"Hello";

Always remember while writing any statement for comparison use '==' instead of '=' because '=' is use to assign the values instead of comparison.

5. Undeclared Functions:

void main()
{
hello();
}
void hello()
{
//
//
}

Always remember to put either a prototype for the function or the entire definition of the function above the first time you use the function.

6. Extra Semicolon:

void main()
{
if(1);
 cout <<"Hello";
}

Remember, the semicolon ';' never goes after the if, for, while, do while or functions statements else the program will function improperly.

7. Over Stepping the boundaries of array definitions or variables is also a major error done by the user which results into the incorrect results.

8. Misuse the && or || operators. Study the De Morgans Law instead.

Happy Coding :)

0 comments:

Post a Comment

 
Design by Free WordPress Themes | Bloggerized by Lasantha - Premium Blogger Themes | Online Project management