1.Syntax Error
Occurs when rules of programming language are violated.
ex.
void main
{
cout "hello";
}
There are 2 errors :-
main --> main()
cout "hello"; --> cout<< "hello";
ex.
void main
{
cout "hello";
}
There are 2 errors :-
main --> main()
cout "hello"; --> cout<< "hello";
2. Semantics error
Occurs when statements are not meaningful.
ex.
X*Y=Z;
it should be Z=X*Y;
ex.
X*Y=Z;
it should be Z=X*Y;
3. Type errors
Occurs when a particular data type variable is assigned another type value that it can not convert.
ex.
int a
a="hi";
ex.
int a
a="hi";
4. Run time errors
Occurs during the execution of program caused due to illegal operations. These are sometimes hard to detect as the compiler will not report them.
ex.
int a,b=9,c=0;
a=b/c;
here the program will crash due to DIVIDE ERROR by 0.
ex.
int a,b=9,c=0;
a=b/c;
here the program will crash due to DIVIDE ERROR by 0.
5. Logical errors
produces wrong output due to negligence of user.
ex.
ctr=1;
while(ctr>10)
{
cout << n*ctr;
ctr = ctr +1;
}
Here loop would not be executed even once.
ex.
ctr=1;
while(ctr>10)
{
cout << n*ctr;
ctr = ctr +1;
}
Here loop would not be executed even once.