What is Bug


Error:
                The mistake in the computer program is called the error of the program. It is also called bug. If the program has any type of error it does not work properly.

Type of errors / bugs:
                There are three kinds of error can be occurring in computer program:-

     Syntax error 
         Logical error
     
Runtime error

Let’s have a short introduction to these kinds of error or bugs.


Syntax error:
                There are some rules to write a program in every computer programming language. These rules are called syntax of that language. The error in the syntax of program is called the syntax error. If program has any syntax error it does not execute the program.

                                For example:
                                cout<<”Ali haider is a good programmer”

                There is semicolon missed as a terminator. The program has a syntax error.

Logical error:
                                This error is occurred due to put wring logic by programmer. If program has a logical error it can execute but not give us proper result.

For example:

                                If programmer wants to add up two figures he should write the code just like that.
            int a=20;
int b=10;
int sum;
sum=a+b;

cout<<”The sum is: ”<<sum<<endl;
thus he get the right answer that is 10+20= 30
but if programmer write the lines like that
int a=20;
int b=10;
int sum;
sum=a*b;
cout<<”The sum is: ”<<sum<<endl;

The programmer wants to get the addition of two numbers and he put wrong logic as he use multiply operator (*) instead of addition operator (+). By this the program compile and execute and but does not give us the proper desired result.
Now the result will be 200.

Runtime error:
                This error occurs when we demand something from the program which is can’t do. It is the type of error which is occurs on the time of execution of the program.
For example:

Some of the common runtime errors are these:-
Use variable in the loop without initialization. 
          Use the value of variable when the variable does not have any value. 
          Divide something by zero
          Use a local variable as global.

Comments

Popular posts from this blog

Umbrella activities in Software Engineering

Operating System | Best Definition of Opetating System